this is my code:
HTML:
<div>
<input type="button" id="btnEnable" value="Enable" />
<input type="button" id="btnDisable" value="Disable" />
</div>
<div id="myDiv">Some Text</div>
<textarea rows="5" id="someText" data-bind="enable: enableText"></textarea>
css:
.enabled{
background-color: green;
}
.disabled{
background-color: red;
}
javascript:
$(document).ready(function () {
$("#myDiv").addClass("enabled").html(" Enabled");
$("#btnEnable").click(function () {
$("#myDiv").removeClass("disabled");
$("#myDiv").addClass("enabled").html(" Enabled");
});
$("#btnDisable").click(function () {
$("#myDiv").addClass("disabled").html(" Disabled");
$("#myDiv").removeClass("enabled");
});
var viewModel = function(){
enableText = ko.observable(true)
}
ko.applyBindings(viewModel);
});
when i click on the disable button, the enabled css class is removed. At this point, i need to disable the textarea by KO observable viewModel.
var viewModel = function(){
enableText = ko.observable(here must return false when the enable css class is removed)
}