Skip to content

Instantly share code, notes, and snippets.

@taxilian
Created August 25, 2011 19:59
Show Gist options
  • Save taxilian/1171696 to your computer and use it in GitHub Desktop.
Save taxilian/1171696 to your computer and use it in GitHub Desktop.
Example of using a generic handler with anonymous functions
// Don't do this on something real! It'll leak!
function myHandler(obj, param1, param2)
{
alert("Some object " + obj + " fired an event with " + param1 + " and " + param2;
}
function pluginOnLoad(plugin)
{
plugin.addEventListener("coolevent", function(p1, p2) { myHandler(plugin, p1, p2); });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment