I am using knockout and i am quiet new to it , i have a certain condition in which i have to define some read only properties in my model .
and later on i want to check the status/state of property that the field is read-only or not .
I searched hours on Google but find no suitable solution . what i find is this fiddle .
var ViewModel = function() {
var self = this;
self.getDisabledState = ko.observable(null);
self.getreadonlyState = ko.observable(null);
self.enable = function() {
if (self.getDisabledState()) self.getDisabledState(undefined);
else self.getDisabledState('disabled');
}
self.readonly = function() {
if (self.getreadonlyState()) self.getreadonlyState(undefined);
else self.getreadonlyState('readonly');
}
}
ko.applyBindings(new ViewModel());
So i wonder if anybody help me .
Thanks in advance .