gvas / knockout-jqueryui

Knockout bindings for the jQuery UI widgets.
http://gvas.github.com/knockout-jqueryui/
MIT License
103 stars 38 forks source link

autocomplete and two way binding #49

Open pathsny opened 9 years ago

pathsny commented 9 years ago

Is there a way to setup two way binding with autocomplete. As it is autocomplete uses objects with label and value properties. What would be ideal is if the autocomplete widget could get proper two way binding with an observable, and the value of the widget was always set to the label.

mryellow commented 9 years ago

Doable for simple lists of values without related ids.

http://stackoverflow.com/a/17060235/2438830

This may suit my use-case as I'm using denormalised data and another copy of the name is no big deal.

Related keys aren't dumped in the HTML attributes so can't lookup the related menu item and trigger menuselect as you need the related dropdown element.

The source function itself is interesting, takes a term and triggers a callback with the matching object, however we need the reverse of that. The filter function only checks value and label.

Not seeing anything on the jQuery end which could be used to hook in, it's all tied to the dropdown elements themselves. Could be extended to do so, but not sure how their release schedule works...