How can one pass multiple arguments along with an event object to an event handler without using Function.prototype.bind
?
The event handler has a closure in it.
The below basic code won't work,
element.addEventListener("click", eventHandler(eventObj + arguments), false);
function eventHandler(eventObj + arguments) {
return function(){}; //a closure
}
I don't know how to pass event object and other arguments at the same time to an event handler.
Updated:
I have even tried using anonymous function inside addEventListener. Doing so, it seems that the control never reached to the closure inside the callback function.
element.addEventListener("click", function(e){
var data = {'event':e, 'args':arguments};
eventHandler(data);
}, false);
function eventHandler(data) {
return function(){ //this function is never executed
console.log(JSON.stringify(data));
};
}