The goal is to disable all the links, when one is clicked, and then disable all the links until the server sends an undisable command (using a similar method that would be used to disable).
So, since all the links are in one containing div, I figure I could just temporarily disable that.
How would I go about doing that?
If you just want to disable the default link behaviour, you can use a combination of delegate
and event.preventDefault
:
$('#container').delegate('a', 'click', function(e) {
if (linksDisabled) {
e.preventDefault();
}
});
You can then set linksDisabled
(in a parent scope) to true
or false
in your other event handlers as appropriate.
If these links are doing Javascripty things, it's a bit trickier. It would probably be easiest to put the if (linksDisabled)
check in each event handler.
Try this:
$("#YOUR_DIV a").click(function(){
return false;
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With