Skip to content Skip to sidebar Skip to footer

Knockoutjs Double Binding Widget Application

I have a scenario where I've developed a widget based application, which injects itself into the DOM of a consuming application. That widget uses KnockoutJS to render it's own UI,

Solution 1:

I think you will need to scope your second apply bindings just to your widget containing div which is only added to the DOM after your widget loads and after your first applyBindings is called.

So the widget would call

ko.applyBindings(widgetViewModel, $widgetDiv);

This will stop them treading on each others toes.

As for having two versions of KO on the page, I'm not sure what the consequences are. Could you test for ko object and if not found include your files dynamically?

Hope this helps.

Post a Comment for "Knockoutjs Double Binding Widget Application"