Skip to content

Instantly share code, notes, and snippets.

@RStankov
Created April 8, 2011 15:25
Show Gist options
  • Save RStankov/910097 to your computer and use it in GitHub Desktop.
Save RStankov/910097 to your computer and use it in GitHub Desktop.
// before
$(document).delegate("#login-form", "submit:successful", function(e) {
var subEvent = new jQuery.Event("login:success");
$(this).trigger(subEvent);
if (subEvent.isDefaultPrevented()) {
e.preventDefault();
}
});
// after
$(document).delegate("#login-form", "submit:successful", function(e) {
$(this).trigger(e.sub('login:success'));
});
(function() {
Event.prototype.sub = function(type){
var subEvent = new Event(this);
subEvent.type = type;
return subEvent;
};
})(jQuery.Event);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment