I am trying to figure out how I can set arguments for custom events. How can I set an argument when subscribing to an event, and then add some extra data when I fire the event.
I have a simple JS for testing, but in the “handle” e-parameter, I see only the subscription data.
function handle(e) {
alert(e.data);
}
function myObj() {
this.raise = function () {
$(this).trigger("custom", { a: "a" });
}
}
var inst = new myObj();
$(inst).bind("custom", { b: "b" }, handle);
inst.raise();
Thank.
source
share