Skip to content

Commit 9384d69

Browse files
committed
add pubsub description and change heading
1 parent 7a23224 commit 9384d69

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

content/events/triggering-event-handlers.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ There are four differences between <code>.trigger()</code> and <code>.triggerHan
4747

4848
For more information see the [triggerHandler documentation](http://api.jquery.com/triggerHandler)
4949

50-
#### Don't use <code>.trigger()</code> to control your application
50+
#### Don't use <code>.trigger()</code> simply to execute specific functions
5151

5252
While this method has its uses, it should not be used simply to call a function that was bound as a click
5353
handler. Instead, you should store the function you want to call in a
5454
variable, and pass the variable name when you do your binding. Then, you can
5555
call the function itself whenever you want, without the need for
56-
`$.fn.trigger`.
56+
`$.fn.trigger`.
5757

5858
<javascript caption="Triggering an event handler the right way">
5959
var foo = function(e) {
@@ -69,3 +69,6 @@ call the function itself whenever you want, without the need for
6969
foo(); // instead of $('p').trigger('click')
7070
</javascript>
7171

72+
A more complex architecture can built on top of trigger using the [publish-subscribe pattern](http://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern) using [jQuery plugins](https://gist.github.com/661855).
73+
With this technique, `$.fn.trigger` can be used to notify other sections of code that an application specific event has happenned.
74+

0 commit comments

Comments
 (0)