I have a Chrome Extension that, in a content script, listens for specific events on the page it is injected into.
The listeners are created on a focusin event - because the elements I want to listen for only exist in certain situations.
Everything works great...except every time the user focusins (understandably) new listeners are created. So I end up with many duplicate events.
My Extension works with very specific pages, so I know whether they have Jquery or not...this one does.
In the focusin listener I have:
$('.PageClass_I_listen_for').blur(function(){
console.log('blurred out of comment area...');
//Do something
});
I've tried including 'off' commands at the start of the focusin listener - to kill any existing event listeners before adding a new one. The following code does not have any effect:
$(document).off('click', '.PageClass_I_listen_for'); // Kill events
Perhaps you cannot kill events (understandably) that are part of a page into which your code is injected?
Any way to get around this?
Help appreciated!