Reputation: 105
I have an input box and I am binding its value to a value in my viewmodel. But it is not binding. I have no idea why.
That is the input box markup:
<input data-bind="value : $root.rootData.Page(), valueUpdate:'afterkeydown'" class="form-control" placeholder="Jump to ...">
Here I am sending the value entered by the user to my function in JS:
<button type="button" class="btn btn-default" data-bind="click: $root.selectPage.bind($root, $root.rootData.Page())"> Search! </button> // This does not works
<button type="button" class="btn btn-default" data-bind="click: $root.selectPage.bind($root, parseInt(7))"> Search! </button> // This works, I get 7 at the JS function.
In the JS function, I am getting the old value. If I send a constant value, such as 7, it works, and I get it in my JS function. So it means the input box binding is not working. Any idea why the input binding is not working?
Upvotes: 0
Views: 127
Reputation: 2397
You don't need to unwrap the observable in the binding, try "value:$root.rootData.Page"
Upvotes: 1