javascript - How to remove an event out of content script scope? -
i'm trying unbind event specific element , upon research, found this. useful. in itself. didn't know that. but:
is there way make work in browser/chrome extension? i'm talking content scripts.
the reason why doesn't work way it's described there website has attached event in question own script using different jquery object 1 in extension's includes/
folder. , can try search event via jquery._data(el, 'click');
my jquery object, not 1 of website events apparently stored. i'm glad figured that out after hours of fiddling around.
or maybe possible access website's jquery object itself?
edit:
what i'm trying achieve works in theory … it's complicated. original script uses plugin event , keeps reinstalling .on('mouseleave',…
.
anyway, got you, pdoherty926:
var $el = $('div.slideshow'); $('h2', $el).click(function(){ console.log('ouch!'); }); // test event var $slides = $('.slides', $el).detach(); $copy = $el.clone(false); $slides.prependto($copy); $el.replacewith($copy);
the test event doesn't triggered event i'm trying remove still fires. can imagine figuring out, though, got closer goal.
edit:
okay, aforementioned re-installation on mouseleave fucked otherwise satisfying suggestion. (the site using jquery timer plug-in cyntaxtech). here's how solved instead: changed class name (-.-' )
re-installation code cannot find element anymore.
this how finished script looks like:
function stop_happening() { var $el = $('div.fullwall div.slideshow'); $el // first, stop current automation. .timer('stop') // timer plug-in // next, change class name in order prevent timer // being started again. .removeclass('slideshow').addclass('slideshow-disabled-automation'); //--- copied code website onclick // events supposed keep working. wish *that* // programmatically i'm glad got far got. ---// // […] }
Comments
Post a Comment