Skip to content

Instantly share code, notes, and snippets.

@merbjedi
Created February 14, 2010 07:21
Show Gist options
  • Save merbjedi/303891 to your computer and use it in GitHub Desktop.
Save merbjedi/303891 to your computer and use it in GitHub Desktop.
// jquery fire() allows you to easily trigger jquery events with named arguments
// e.g. $(".myelement").fire("customEvent", {arg1: "say", arg2: "hello"});
// in your event, just use e.arg1, and e.arg2 to access these variables
;(function($) {
$.fn.fire = function(eventName, arguments){
var arguments = arguments || {};
arguments["type"] = eventName;
this.trigger(arguments);
}
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment