I have a difficult question.
events = $._data( element[0], 'events');
$.each(events, function(_event_name, _event_handler){
var _handlers=[];
for(var i= 0 ;i < _event_handler.length;i ++)
_handlers.push(_event_handler[i].handler);
event_handler.push(_handlers);
event_name.push(_event_name);
});
element.off();
I have above code to successfully read all what event name
and its handler
assigned for a element.
Then I save each of them into event_name
and event_handler
before I turn the events off;
However, this method is only work on when the events are directly assigned for the element.
When the events are delegated assigned, how can I develop the code to do that?
$(document).on('click', '#id', handler);
Above code will only show the event name click
and its handler handler
, but no the name or selector of the delegate assigned element #id
.
I want to know how can I read the name of delegate assigned element out that I can do delegate off or all the events on parent will be off.
Thank you very much for your advice.