Skip to content

Trigger: add note about objects with a length property #716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions entries/trigger.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ $( "#foo").trigger( "custom", [ "Custom", "Event" ] );
<p>The <code>.trigger()</code> method can be used on jQuery collections that wrap plain JavaScript objects similar to a pub/sub mechanism; any event handlers bound to the object will be called when the event is triggered. </p>
<div class="warning"><strong>Note:</strong> For both plain objects and DOM objects other than <code>window</code>, if a triggered event name matches the name of a property on the object, jQuery will attempt to invoke the property as a method if no event handler calls <a href="/event.preventDefault/"><code>event.preventDefault()</code></a>. If this behavior is not desired, use <a href="/triggerHandler/"><code>.triggerHandler()</code></a> instead.</div>
<div class="warning"><strong>Note:</strong> As with <a href="/triggerHandler/"><code>.triggerHandler()</code></a>, when calling <code>.trigger()</code> with an event name matches the name of a property on the object, prefixed by <code>on</code> (e.g. triggering <code>click</code> on <code>window</code> that has a non null <code>onclick</code> method), jQuery will attempt to invoke that property as a method.</div>
<div class="warning"><strong>Note:</strong> When triggering with a plain object that is not array-like but still contains a <code>length</code> property, you should pass the object in an array (e.g. <code>[ { length: 1 } ]</code>).</div>
</longdesc>
<example>
<desc>Clicks to button #2 also trigger a click for button #1.</desc>
Expand Down