javascript - MutationOberserver should observe iframes -
currently use observer attach click event first event handler dynamically created elements. unfortunately doesn't work elements within dynamically created iframe.
elementobserver = new mutationobserver(function (mutations) { mutations.foreach(function (mutation) { $(mutation.target).bindfirst('click', my.callback.function); }); }); elementobserver.observe(document.body, {childlist: true, subtree: true});
the bindfirst()
function looks like:
$.fn.bindfirst = function(name, fn) { this.on(name, fn); this.each(function() { var handlers = $._data(this, 'events')[name.split('.')[0]]; var handler = handlers.pop(); handlers.splice(0, 0, handler); }); };
but my.callback.function
won't triggered within iframe. how can solve problem my.callback.function
gets triggered in iframe well.
Comments
Post a Comment