SteveSanderson/knockout — Issue #210: Multiple template calls reinitialize bindings
Author: TimOrme
Created: 2011-11-22 23:19:21+00:00
State: open

In the 1.3 beta I've found an issue with templating that I've been unable to work around.

The problem is that when you use a template multiple times, the template is reinitialized each time and the bindings are redone. This is problematic when the binding makes stateful changes to the template, such as with jQuery UI elements.

Here is the problem in 1.3

http://jsfiddle.net/UbnK8/5/

And the equivalent code with 1.2.1

http://jsfiddle.net/SGKfD/1/

As you can see, in 1.3 the button is initialized multiple times and therefore cell padding expands out on each call.

It's particularly odd, because even if I try and check that the element isn't already initialized as a button, the template that is passed in doesn't seem to "know" that the element is already initialized.

Thanks,
Tim