I am trying to have the functionality of the jQuery selectable list when using KnockoutJS, but can’t get it to work.
Using Custom Bindings I was successful in transforming ul element in a selectable one and creating events handlers for the selected and unselected events. But what do I pass to my ViewModel functions which maintain the selected elements?
Here is my code so far: http://jsfiddle.net/QCmJt/
I am new to all this, so maybe I am approaching this the wrong way…
Ok, I figured a way to pass the data bound to the selected item:
$(ui.selected).tmplItem().datawhen selecting and$(ui.selected).tmplItem().datawhen unselecting.Here the updated fiddle: http://jsfiddle.net/8RnxC/
Custom binding looks like:
And my view model: