Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

knockout.js

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?

like image 720
nnpath Avatar asked Aug 10 '11 22:08

nnpath


1 Answers

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

like image 140
RP Niemeyer Avatar answered Oct 14 '22 10:10

RP Niemeyer