0

I've been using this knockout binding from this jsfiddle (from this initial SO question) for a while and it has been working.

After upgrading to jQuery 1.8.3 and jQuery UI 1.9.2 (jsfiddle), when typing text into the input, after the items list is populated (but not selected!), the input textbox is cleared and you have to restart typing from the beginning. That's annoying as you won't be able to complete your text input because you always have to start from scratch.

If the jqAutoSourceInputValue and the jqAutoSourceValue have the same property name, it works, but then either the id or the input value after the selection are not the desired one.

Community
  • 1
  • 1
Alexander Zeitler
  • 11,919
  • 11
  • 81
  • 124

1 Answers1

2

Looks like the issue is coming from the fact that the binding's update function has a dependency on the observableArray that is being updated. I am not quite sure what has changed in jQuery UI to make the actual behavior change from before, but one fix is to update to Knockout 2.2.1 and access the observableArray via the peek function to avoid a dependency. Something like:

var source = (ko.isObservable(allBindings.jqAutoSource) ? allBindings.jqAutoSource.peek() : allBindings.jqAutoSource) || [];

Updated fiddle: http://jsfiddle.net/rniemeyer/xXuq6/

If you can't update to KO 2.2.1, then there are some other ways to do it as well. Let me know.

RP Niemeyer
  • 114,592
  • 18
  • 291
  • 211