I can’t seem to get my custom binding handler for ddSlick (an image based drop down list jQuery plugin) to work correctly.
I can always get it to bind on static data, but for some reason, KO won’t call the binder’s update method once ddSlick has been initialized. It is crazy! I can actually remove the $(element).ddslick() call from the custom binder, and once again the update method will be called!!
Please feel free to test my code using either this link (easier to debug with) http://mjf.me/Dev/ddSlickBinder.html
or this JS Fiddle
http://jsfiddle.net/farina/JSTUA/1/
Thanks in advance!
http://jsfiddle.net/amtiskaw/nEVsP/
There was actually a couple of problems here. Firstly, the ddslick plugin replaces the element it is called on. Knockout detects when the div is removed and cleans up its registered bindings, hence why the slickIt update was never called more than once. I solved this by adding a child div and calling the plugin on that instead.
The second is that ddslick will ignore subsequent attempts to initialise it on the same element. I have solved this by calling ‘destroy’ beforehand, in order to remove any pre-existing ddslick instance.