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?
您不需要解开绑定中的可观察对象,请尝试“ value:$ root.rootData.Page”
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.