I’m creating a BHO and inserting scripts into facebook pages..my question is the following. Sometimes when I insert a script into a page(let’s say) and bind some events to an event holder i.e.
$('#contentArea').on('click','#myId',Dosomething);
they work fine.
After this, I remove the scripts from this page, and then add them back again(pls don’t ask why, it’s because facebook doesn’t always generate a new document for a new page, rather it changes a portion of the document), and this time the events run multiple times(depends on how many times do I remove and then add them, so for 1 remove and 1 add they run twice, for 2 remove and 2 adds they run 3 times etc.) despite the facet that the first line of the script is
$('#contentArea').off();
What am I missing here, cause I know the handlers do not get removed from the document, or the node…maybe it’s an event bubbling problem?
BTW, I’m working in internet explorer 9.
i think you should at least do
or the event listener may not be removed , maybe even