01.02.2018, 13:14
You can also attach custom events to a plain object via jQuery:
Code:
var myobj = $({});
myobj.on('myevent', function(event, p1, p2) {
console.log(event, p1, p2);
});
myobj.trigger('myevent', [ 'param1', 'param2' ]);