Skip to content

Commit

Permalink
shorcut methods for triggering events
Browse files Browse the repository at this point in the history
Before these shortcut methods could only attach event handlers. Now, if
the handler isn't given, simply trigger the event.
  • Loading branch information
mislav committed Oct 3, 2012
1 parent f146537 commit 9b46bcf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/event.js
Expand Up @@ -204,7 +204,11 @@
;('focusin focusout load resize scroll unload click dblclick '+
'mousedown mouseup mousemove mouseover mouseout '+
'change select keydown keypress keyup error').split(' ').forEach(function(event) {
$.fn[event] = function(callback){ return this.bind(event, callback) }
$.fn[event] = function(callback) {
return callback ?
this.bind(event, callback) :
this.trigger(event)
}
})

;['focus', 'blur'].forEach(function(name) {
Expand Down

0 comments on commit 9b46bcf

Please sign in to comment.