rniemeyer / knockout-jqAutocomplete

knockout-jqAutocomplete is a Knockout.js plugin designed to work with jQuery UI's autocomplete widget.
MIT License
49 stars 20 forks source link

Changing the observable is not reflected in jqAuto's input box #12

Closed mgehre closed 9 years ago

mgehre commented 9 years ago

Please see the fiddle at http://jsfiddle.net/njLqrgL9/4/.

To reproduce: Enter "item 0" into the input box. Press enter You see "item 0" in input box and in pre

Expected: After pressing enter, input box should be empty and "item 0" only in pre.

Explanation: The submit callback clears the observable that is bound to jqAuto's value. But this is not reflected in the value of the input box. There seems to be some problem in jqAuto's update(), which fails to change the value of the input box.

LiamTalbot commented 9 years ago

I got around this issue by doing the following. Not very elegant since it's tying the the viewmodel to the view, but hopefully it helps someone until a fix comes through.

self.searchValue('');
$('#searchValue').val('');
$('#searchValue').triggerHandler('change');
rniemeyer commented 9 years ago

@mgehre @Seasoln - I made a fix (in v0.4.2) to ensure that when an observable value becomes empty (null, undefined, "") that the field will be properly cleared. Please let me know if you still have any issues. Sorry for the delay in responding.