我真正想要的是,如果 selectedPropertyType 只是产权保险,那么只需禁用该输入字段,即“title_servies_fee”
this.title_service_fee = ko.computed(function(){
if(this.selectedPropertyType() == 'purchase') {
return 200;
}
else if(this.selectedPropertyType() == 'cash-purchase') {
return 200;
}
else if(this.selectedPropertyType() == 'refinance') {
return 150;
}
else if(this.selectedPropertyType() == 'title-insurance-only') {
return 200;
}
else {
// here i want to disable the "title_service_fee" input field
}
}, this);
最佳答案
您必须将 data-bind
属性添加到您的 input
元素,如下所示:
<input data-bind="disable: selectedPropertyType() === 'title-insurance-only'" />
更多信息 here .
关于javascript - 如何使用 knockout js 启用/禁用输入字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34989407/