Currently i am using knockout 2.1.0 where following datepicker binding working perfectly for non observable value.When i have updated knockout 3.0 it is not working
ko.bindingHandlers.datepicker = {
init: function(element, valueAccessor, allBindingsAccessor) {
// Get the options from the binding.
var options = allBindingsAccessor().datepickerOptions || {};
$(element)
.datepicker(options)
.bind("change", function() {
ko.bindingHandlers.datepicker.updateValue(element, valueAccessor, allBindingsAccessor);
});
ko.utils.domNodeDisposal.addDisposeCallback(element, function() {
$(element).datepicker("destroy");
});
},
update: function(element, valueAccessor, allBindingsAccessor) {
var value = ko.utils.unwrapObservable(valueAccessor());
// If the date is coming from a Microsoft webservice.
if (typeof value === "string" && value.indexOf('/Date(') === 0) {
value = new Date(parseInt(value.replace(/\/Date\((.*?)\)\//gi, "$1")));
}
var currentDate = $(element).datepicker("getDate");
// Check if the date has changed.
if (value && value - currentDate !== 0) {
$(element).datepicker("setDate", value);
}
},
updateValue: function(element, valueAccessor, allBindingsAccessor) {
var observable = valueAccessor(),
dateValue = $(element).datepicker("getDate");
// Two-way-binding means a writeable observable.
if (ko.isWriteableObservable(observable)) {
observable(dateValue);
return;
}
if (allBindingsAccessor()._ko_property_writers) {
allBindingsAccessor()._ko_property_writers.datepicker(dateValue);
}
}
};
When i debug the code i came to know that is allBindingsAccessor()._ko_property_writers
is undefined .because of which i am not able to update the nonobservable value.
Can anybody suggest me the solution for above code in 3.0 version
By using below example i have modified the my custom binding and it is working great .Please find the Updated fiddle