34
rated 0 times
[
38]
[
4]
/ answers: 1 / hits: 75112
/ 12 Years ago, sat, march 3, 2012, 12:00:00
When adding a change event binding to an input box using knockout.js the old value is passed to the change function when the event is fired. I can work around this by using blur. Is this the intended behavior? Is the idea to use the change event to have the old value and then use a normal selector to get the value from the dom? It seems counter intuitive.
JavaScript
----------
var data = {
saved_value:1,
value_changed: function(data){
alert(data.saved_value());
}
};
var viewModel = ko.mapping.fromJS(data);
ko.applyBindings(viewModel);
HTML
----
Current Value:<span data-bind=text:saved_value></span><br/>
<input data-bind=event:{change:value_changed},value:saved_value></input>
More From » knockout.js