Skip to content

Commit bb4da5e

Browse files
committed
Trigger: add note about objects with a length property
Fixes jquerygh-377 Closes jquerygh-716
1 parent 9840ff0 commit bb4da5e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

entries/trigger.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ $( "#foo").trigger( "custom", [ "Custom", "Event" ] );
4646
<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>
4747
<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>
4848
<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>
49+
<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>
4950
</longdesc>
5051
<example>
5152
<desc>Clicks to button #2 also trigger a click for button #1.</desc>

0 commit comments

Comments
 (0)