简体   繁体   English

禁用的下拉选项在语义 UI 中不起作用

[英]Disabled dropdown option didn't work in semantic UI

This is my Cshtml这是我的 Cshtml

<div class="field">
    @Html.LabelFor(modelItem => modelItem.plateNumber)
    @Html.DropDownListFor(m => m.plateNumber, new SelectList(ViewBag.PlateNoList, "Value", "Text"),
    "", new { Class = "ui selection dropdown document-type" })
</div>
</div>
<div class="field">
    @Html.LabelFor(modelItem => modelItem.FuelType)
    @Html.DropDownListFor(m => m.FuelType, new SelectList(ViewBag.FuelType,"Value","Text"),
    "", new { Class = "ui selection dropdown fuel-type",@id="FuelType"/*, @disabled = "true"*/ })
</div>

This is my JavaScript这是我的 JavaScript

document.getElementById("FuelType").disabled = true;

$('#plateNumber').change(function() {
    $('.ui.dropdown').dropdown();
    document.getElementById("FuelType").disabled = false;
});

When the plateNumber dropdown is selected, the bottom FuelType dropdown should be available, but it cannot be used even though the plateNumber dropdown is selected, any idea?选择 plateNumber 下拉菜单时,底部的 FuelType 下拉菜单应该可用,但即使选择了 plateNumber 下拉菜单也不能使用,知道吗?

Try removing the disabled class from the dropdown as well.也尝试从下拉列表中删除disabled的 class。 This is checked (and added) internally by SUI.这是由 SUI 在内部检查(并添加)的。

document.getElementById("FuelType").disabled = true;

$('#plateNumber').change(function() {
    document.getElementById("FuelType").disabled = false;
    $('.ui.dropdown').dropdown();
    $('.ui.dropdown').removeClass('disabled');

});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM