I'm currently working on a chrome extension where I need to prevent a default click action on any page the extension is loaded on. Normally I would just do something like the below to prevent a default action:
$('.some-element').click(function(e){
e.preventDefault()
// some other code
});
I'm using the same approach here with my extension but what i'm finding is that sometimes this will work and other times not. For example if I go to a site where an <a>
tag in an area of the page has already had a preventDefault bound to it then the preventDefault of that website will prevent my event from running..
How does the hierarchy of the click events work - is it that the first function that was loaded in will always fire first? If so is there a way I can impose a hierarchy on events so that my event will always fire first therefore preventing any other actions loaded on the page?
The action that already exists on the page needs to only be temporarily disabled so an approach where I completely unbind all events might not be suitable if I can't bind them again..
Thanks