bobber205
bobber205

Reputation: 13372

Observable not updated from programatically changed INPUT, even when trigger()'ed

This includes setting via just

.val();

and using

.val().trigger("change");

I've tried both.

I've come up with the simplest example I can manage.

http://jsfiddle.net/hEtE9/2/

If you click the button that updates the someText observable with some random number string, the computed updates as well. If you use jQuery to change the input both the text and the computed are not updated.

What's up?

Upvotes: 1

Views: 63

Answers (1)

Anthony Chu
Anthony Chu

Reputation: 37520

This has stumped me before. jQuery needs to be loaded before Knockout in order for change() or trigger('change') to change the view model.

<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//ajax.aspnetcdn.com/ajax/knockout/knockout-3.0.0.js"></script>

Fiddle: http://jsfiddle.net/qP9NW/

Upvotes: 1

Related Questions