I have a textbox bound to a custom binding. For the sake of an example all it does it wrap the control with a bordered div. I then pass the bound observable to the value binding but it is not updating the underlying observable as I'd expect.
=Html=
<body data-bind="with: model">
<textarea data-bind="wrapbox: someval" ></textarea>
<textarea data-bind="value: someval" ></textarea>
<div data-bind="text: someval"></div>
</body>
=Js=
ko.bindingHandlers.wrapbox = {
update: function(element, valueAccessor)
{
var value = ko.unwrap(valueAccessor());
$(element).wrap("<div class='border' />");
return ko.bindingHandlers.value.update(element,
function(){return value; });
//return ko.bindingHandlers.value.update(element,
// valueAccessor()); <---- tried this too.
}
};
var viewmodel = function() {
var model = {};
model.someval = ko.observable();
return {
model: ko.observable(model)
};
}();
ko.applyBindings(viewmodel);
=Example=