Thursday, 15 September 2011

javascript - js, check the child name or selector from parent from a delegate assigned event -



javascript - js, check the child name or selector from parent from a delegate assigned event -

i have hard 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 read event name , handler assigned element.

then save each of them event_name , event_handler before turn events off;

however, method work on when events straight assigned element.

when events delegated assigned, how can develop code that?

$(document).on('click', '#id', handler);

above code show event name click , handler handler, no name or selector of delegate assigned element #id.

i want know how can read name of delegate assigned element out can delegate off or events on parent off.

thank much advice.

the selector stored in object within array of click events under selector seen below.

it seems selector field empty when @ click events bound straight element.

i assume can build check code somehow. mind you, selector property apparently intended internal utilize had question myself in past it, when found contained unusual values.

to end, though might work you, not know how reliable or if going used in future versions of jquery.

however, if utilize delegate events might find contains useful values maintain eye on it.

javascript jquery events handler

No comments:

Post a Comment