AnsweredAssumed Answered

Using Knockout with Web AppBuilder

Question asked by chump4life on Oct 21, 2015

Hi,

 

Has anyone have any experience using Knockout with Web AppBuilder?  I manage to incorporate it into a custom widget and it works well.  However, I ran into issue when applying Knockout for multiple custom widgets.  Knockout is giving me the following error.

 

Error: You cannot apply bindings multiple times to the same element.

 

Although I am applying binding by using ko.applyBindings(VM, Element) with element being the container div of my custom widget.  For some reason, it looks like the second parameter is being ignored.  I embed most of my code in the startup routine of each widget.  My goal is to using Knockout either with one viewmodel applied to the entire application (I don't know where to put this code) or multiple viewmodel bind to different elements (that doesn't seem to work either).  Hopefully, someone can offer some advice on what is proper way to implement Knockout in the Web AppBuilder.  Or using data binding with templating technique with another library similar to Knockout.  Thanks.

 

Steve

 

Edit:  After coming back to this, I still can't get Knockout to work.  So I switched to Rivets.js and it seems to be able to bind different models to different custom widgets.  So give Rivets a try if you want to employ data binding and templating in a custom widget.

Outcomes