I have an object literal pattern used in a code and I'm trying to pass the object name as reference to another function using 'bind'. I also need to pass a second parameter but when I do this I lose access to 'event' object.
var obj = {
init: function() {
this.trig();
},
trig: function() {
$('.addButton').on('click', this.doSomething.bind(this, secondParameter))
},
doSomething: function(e,args) {
e.preventDefault(); // erroring here e.preventDefault is not a function
//rest of the code
}
}
obj.init();
Any idea how I can send a second parameter whilst still having access to event object?