5 Aug 2009

triggerHandler on live event bindings in jQuery

Posted by havvg

As stated in the jQuery API Documentation, the triggerHandler() method does not work on events bound to objects using the live() method, which includes also objects created after the DOM was loaded completely.

However, this is nothing unusual. In fact, it might be a common way to work within an advanced AJAX enabled webapplication. I encountered this problem this evening and also created a simple workaround. The following code snippet works just fine.

?View Code JAVASCRIPT
var event = new $.Event('click');
event.preventDefault();
$('input:submit', $(this)).trigger(event);

Tags:

Leave a Reply

Message: