2
obj.on('evt_A evt_B evt_c', function(eventData){
console.log("Is it possible here to find which event is triggered. As this callback is registered for three events. This callback is like a central callback for all the events on this object.")
})

obj.trigger('evt_A evt_B evt_c', [{eventDataForevt_A}, {eventDataForevt_B, {eventDataForevt_C}}])

There is one way of doing it, which is having a property in eventDataForevt_<A||B||C> which says the name of the event. But is it possible to do this without modifying the eventDataForevt_<A||B||C> ?

Rajkamal Subramanian
  • 6,884
  • 4
  • 52
  • 69

1 Answers1

0

Check out this fiddle: http://jsbin.com/ucevov/4/edit

It doesn't seem possible to detect the event name from your obj.on - note that evt_c in this._events is true even when evt_c is not called.

However there is a special "all" event which passes in the name of the calling event as the first parameter, so

obj.on("all", function(eventName, eventData) {
  console.log(eventName);
});

should output the name of the event that was called.

David John Smith
  • 1,824
  • 2
  • 18
  • 22