如何解决复选框不启用字段淘汰赛
当“SetAlarmValues”被选中时,我试图为“SetoutputCurrentPPLowValue”和“SetoutputCurrentPPHighValue”设置启用true。对于这个问题,我有以下代码:
当页面加载时这些字段被禁用,但当“SetAlarmValues”被选中时,它们保持禁用状态。我不知道为什么。请帮忙!
<!-- ko if: $root.regData -->
<div class="row">
<div class="col-md-2">
<label for="SetAlarmValues" class="control-label">@MSL.Core.Resource.Models.Well.SetAlarmValues:</label>
<input type="checkBox" data-bind="checked: $root.regData().setAlarmValues" class="large-check registration" id="SetAlarmValuesCheck" title="@MSL.Core.Resource.Models.Well.SetAlarmValues" />
</div>
</div>
<div class="col-md-6">
<div class="row">
<div class="col-md-3">
<label for="SetoutputCurrentPP" class="control-label">Set Output Current PP:</label>
</div>
</div>
<div class="row">
<div class="col-md-1">
</div>
<div class="col-md-5 form-inline">
<label for="SetoutputCurrentPPLowValue" class="control-label">@MSL.Core.Resource.Models.Well.OutputCurrentPPLowValue: </label>
<input type="checkBox" data-bind="checked: $root.regData().setoutputCurrentPPLowValue,enable: $root.regData().setAlarmValues()" class="large-check registration" id="SetoutputCurrentPPLowValue" title="@MSL.Core.Resource.Models.Well.SetoutputCurrentPPLowValue" />
<input type="text" id="OutputCurrentPPLowValue" data-bind="value: $root.regData().outputCurrentPPLowValue,enable: $root.regData().setoutputCurrentPPLowValue" class="form-control" maxlength="30" />
</div>
</div>
<br />
<div class="row">
<div class="col-md-1">
</div>
<div class="col-md-5 form-inline">
<label for="SetoutputCurrentPPHighValue" class="control-label">@MSL.Core.Resource.Models.Well.OutputCurrentPPHighValue:</label>
<input type="checkBox" data-bind="checked: $root.regData().setoutputCurrentPPHighValue,enable: $root.regData().setAlarmValues()" class="large-check registration" id="SetoutputCurrentPPHighValue" title="@MSL.Core.Resource.Models.Well.SetoutputCurrentPPHighValue" />
<input type="text" id="OutputCurrentPPHighValue" data-bind="value: $root.regData().outputCurrentPPHighValue,enable: $root.regData().setoutputCurrentPPHighValue" class="form-control" maxlength="30" />
</div>
</div>
</div>
<!-- /ko -->
这是脚本:
function Registration() {
var self = this;
//Alarms
self.setAlarmValues = ko.observable(false);
self.setoutputCurrentPPLowValue = ko.observable(false);
self.setoutputCurrentPPHighValue = ko.observable(false);
self.outputCurrentPPLowValue = ko.observable("");
self.outputCurrentPPHighValue = ko.observable("");
}
var registerVM = function (countryListJSON,companyListJSON,wellStatusListJSON,territoryListJSON) {
self = this;
self.validation = ko.observableArray([]);
self.savingData = ko.observable(false);
self.regData = ko.observable(new Registration());
}
解决方法
在您的代码中,我看到此语句-启用:$root.regData().setAlarmValues(),并且 setAlarmValues 值已设置为 false。只有将字段 setAlarmValues 的值设置为 true 后,它才会启用。但是正如您提到的,一旦选中复选框,请确保检查该值是否仍然为 false 或是否已更改为 True。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。