Open BorisMoore opened 13 years ago
+1 :)
I have multiple events bound to an element using live. The first event runs tmplItem.update(), but all other events are then lost. None of the subsequent bound events run on the element.
My fix was to trigger an "afterUpdate" event from within the update event which updated the template.
It is better to use delegate. But even using live can work fine. You can also call item.update(), and then get the item.nodes and rebind. Or you can use the rendered event.
You could put a small test case on jsbin or jsfiddle showing the case of the live event not getting triggered. It does work in my example above...
Thanks for taking the time to submit this issue. Just wanted to let you know this plugin is no longer being actively developed or maintained by the jQuery team. See README for more info.
Copied from https://github.com/nje/jquery-tmpl/issues#issue/33:
Created 3 months ago by ethermal if I have a template then I bind a blur event to it then later call the tmplItem.update() function the bound events are lost. this is overridden by using .live instead of .bind. But during an update() is it necessary to destroy & recreate the objects instead of just updating the values?
ps. I noticed a bit of odd behaviour and perhaps I should create another issue for this. If i call tmplItem.update() from within a event handler I cannot set focus back to element. So for example in my template create a table of text fields, I then bind keypress and blur events then as a user tabs their way through the form on each blur I want to recalc totals and taxes which means I need to call tmplItem.update(). After I do that i can't set focus back to the original item or to any item for that matter.
example:
Comments ethermal December 08, 2010 to work around this in the keypress event I had to do this
ethermal December 08, 2010 even timeout wasn't necessary