Knockout.js bound input value not updated when I use jquery .val('xyz')

谁说我不能喝 提交于 2019-12-17 17:33:50

问题


I have an input that has a knockout binding to the value.

When I update the value using jquery's .val() method, the changed value is not reflected in the viewModel.

I need to use jQuery to set this value. How can I trigger the update to the viewModel?


回答1:


.val() does not trigger the change event. So, you can just do .val("blah").change() for KO to pick up the changes.



来源:https://stackoverflow.com/questions/7018885/knockout-js-bound-input-value-not-updated-when-i-use-jquery-valxyz

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!