I use facebox plugin on certain links.
I want to disable some of the links dynamically. so clicking them will not open facebox.
I tried several ways to do it but none of them seem to work. Facebox still works when clicking on the links.
I even tried this (prevent the click and mouse down events) but it still doesn't disable the facebox from popping up.
$('#who_button').click(function(event) { event.preventDefault();});
$('#who_button').mousedown(function(event) { event.preventDefault();});
What can I do?
EDIT:
Following brad and PetersenDidIt advice I tried this:
$('#who_button').click(function(event) { alert ('here');event.stopPropagation(); event.stopImmediatePropagation();});
$('#who_button').mousedown(function(event) { event.stopPropagation(); event.stopImmediatePropagation();});
AND still no luck. Moreover I see that the facebox frame appears under the alert dialog. which means that facebox starts before my click/mousedown events are even called.
Is it possible to attach event which will occur before all other events?
Perhaps facebox uses another event (not click or mousedown). what can it be?
Try event.stopPropagation()
preventDefault just prevents whatever the normal behaviour of that click is (ie redirect on a link).
I've never used facebox, so I'm not sure how it binds its events, but you probably want some thing more like:
EDIT
Looks like facebox uses it's own custom event. You can see this in the source (below). So your best bet is to unbind your element from that event:
Facebox public function