Last active
October 13, 2015 07:27
-
-
Save Hampei/4160154 to your computer and use it in GitHub Desktop.
copy delegated jquery events from one element to another
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function copy_jquery_on_event_handlers(source, target) { | |
$.each(['click', 'submit', 'ajax:beforeSend', 'ajax:complete'], function(i, event_type) { | |
$.each($._data(source, 'events')['click'], function(j, jqe_spec) { | |
if (jqe_spec.selector != undefined) | |
$(target).on(event_type, jqe_spec.selector, jqe_spec.handler); | |
}); | |
}); | |
} | |
copy_jquery_on_event_handlers(body, new_bubble_element); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment