Reputation: 140
What i actually want is that if selectedPropertyType is title insurance only, then just disable that input field, i.e "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);
Upvotes: 1
Views: 115
Reputation: 1370
You have to add data-bind
attribute to your input
element like this:
<input data-bind="disable: selectedPropertyType() === 'title-insurance-only'" />
More information here.
Upvotes: 1
Reputation: 2354
This field is computed, so unless you make it writable it shouldn't be bound to an input.
Apart from that, to make the input read only you need another computed that test your condition and return false when read only condition is reached and bound this new computed to "enable" binding of the input field.
Upvotes: 1