KnockoutJS 2.3.0 - Uncaught Error: You cannot apply bindings multiple times to the same element.

Posted by Aligned on Geeks with Blogs See other posts from Geeks with Blogs or by Aligned
Published on Thu, 25 Jul 2013 02:45:10 GMT Indexed on 2013/08/02 15:40 UTC
Read the original article Hit count: 310

Filed under:

Originally posted on: http://geekswithblogs.net/Aligned/archive/2013/07/25/knockoutjs-2.3.0---uncaught-error-you-cannot-apply-bindings-multiple.aspx

I upgrade KnockoutJs through Nuget and started getting the error ‘Uncaught Error: You cannot apply bindings multiple times to the same element.’ when I used applyBindings after the main page load. I had some dynamically added DOM elements and re-applying bindings worked before. It always seemed like a workaround/hack, but now Knockout is telling me that I shouldn’t do it. The quick way to fix this is to use ko.cleanNode($(‘#id’) and this works. A different/possibly better way, as suggested by x0n might be to use templates and Knockout’s template binding (<script type=’text/html’>…</script>).

 

Thanks again to the StackOverflow community for quickly providing me with the solution. Check out my question for all the details.

© Geeks with Blogs or respective owner