I am trying to trigger custom events in DOM elements and pass anonymous functions that will be executed when the event fires (using jQuery). So something like this:
$(some-dom).live("custom_event", function(evtObj, data, callback) { //do some stuff callback(); }); $(some-button).click(function() { $(some-dom).trigger("custom_event", some_data, function () { alert("this is my anonymous function passed as event data"); } });
Thus, pressing the "some-button" button should start "custom_event" in "some-dom" and call the anonymous function that I passed to the trigger. Right? But the browser says the callback is undefined in the user event. Am I doing something wrong? Skips anonymous functions since trigger arguments are not allowed? Thanks
source share