I have this dropdown which have options if vehicle is new or used.
<select name="VehicleType" id="vehicleTypeDropdown" data-bind="value: VehicleType">
<option value="New" selected="selected">Nuevo</option>
<option value="Used">Usado</option>
</select> `
And this input:
<input type="text" name="Mileage" data-bind="disable: VehicleType() === 'New',value: Mileage" class="input-large"> `
If the value in the dropdown selected is New the input must be disabled, and if used the input should be enabled, but if I enter a value the observable will grab this value and if I change the dropdown value to new the observable must become zero.
A manual subscription in your view model is a good way to handle something like this. The subscription might look like:
Here is a sample using it: http://jsfiddle.net/rniemeyer/h4cKC/
The HTML:
The JS: