Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
46 lines (43 sloc) 2.3 KB
<?xml version="1.0"?>
<entry type="method" name="triggerHandler" return="Object">
<desc>Execute all handlers attached to an element for an event.</desc>
<argument name="eventType" type="String">
<desc>A string containing a JavaScript event type, such as <code>click</code> or <code>submit</code>.</desc>
<argument name="extraParameters" optional="true" type="Array">
<desc>An array of additional parameters to pass along to the event handler.</desc>
<p>The <code>.triggerHandler()</code> method behaves similarly to <code>.trigger()</code>, with the following exceptions:</p>
<li>The <code>.triggerHandler()</code> method does not cause the default behavior of an event to occur (such as a form submission).</li>
<li>While <code>.trigger()</code> will operate on all elements matched by the jQuery object, <code>.triggerHandler()</code> only affects the first matched element.</li>
<li>Events created with <code>.triggerHandler()</code> do not bubble up the DOM hierarchy; if they are not handled by the target element directly, they do nothing.</li>
<li>Instead of returning the jQuery object (to allow chaining), <code>.triggerHandler()</code> returns whatever value was returned by the last handler it caused to be executed. If no handlers are triggered, it returns <code>undefined</code></li>
<p>For more information on this method, see the discussion for <code><a href="/trigger">.trigger()</a></code>.</p>
<desc>If you called .triggerHandler() on a focus event - the browser's default focus action would not be triggered, only the event handlers bound to the focus event.</desc>
<html><![CDATA[<button id="old">.trigger("focus")</button>
<button id="new">.triggerHandler("focus")</button><br/><br/>
<input type="text" value="To Be Focused"/>]]></html>
<category slug="events/event-handler-attachment"/>
<category slug="version/1.2"/>
Jump to Line
Something went wrong with that request. Please try again.