I have problems with my keyup binding when cloning an element. Here\'s the scenario:
I have an html markup like this:
-
You've got two real options
- use clone(true) which will also clone the bound event handlers
- use event delegation with
live()
so that the event handler is bound to a parent element and thus newly added rows will get the same functionality
讨论(0)
-
Use jQuery's live events; this way the handler will automatically be bound to newly created elements (such as the clones in your example).
For example:
$('.rijbasis input').live('keyup', function()
{
var parent = $(this).parent().parent();
$('.total',parent).text(parseInt($('.cost',parent).text()) * parseInt($('.count',parent).val()));
}
讨论(0)
-
Use .live instead of .keyup
讨论(0)
- 热议问题