knockout.jscoverflow

Coverflowjs and Knockout


Using coverflowjs and knockout together doesn't seem to work out of the box.

I'm trying to implement coverflowjs on a div that is wrapped by a knockout with binding.

I have setup a jsfiddle to do some testing. Expected functionality: When the button is pressed, the coverflow with the placehold.it images should show in a coverflow way as the one that's hooked up with the coverflow-noknockout css class.

http://jsfiddle.net/bz8sczqr/21/


Solution

  • Check this: http://jsfiddle.net/gqLd381z/2/. The required change is:

    self.displayCoverflow.subscribe(function () {
        setTimeout(function () {
            $(".coverflow").coverflow();
        }, 0);
    });
    

    The "with" binding is tricky as it add its contents to the DOM only when the condition becomes true. To make Coverflowjs happy you need to use setTimeout(.., 0) which allows everything to settle down before it kicks in.