How to undelegate a click false?

How to undelegate this, and how to re-delegate (on/off)... Without affect the other event handlers in 'a'.

$(document).ready( function() {
    $('document').delegate( 'a', 'click' function(){return false;} ); 
});

Answers


Do something like this, I'm using the click.myEvent to create my own namespace within the click event, so this way it will only be .myEvent events that get generated and removed.

Deletate

$(document).ready( function() {
    $('document').delegate( 'a', 'click.myEvent', function(){return false;} ); 
});

Undelegate:

$(document).ready( function() {
    $('document').undelegate( 'a', 'click.myEvent' ); 
});

With event delegation, if there's going to be regular switching on and off, easiest thing to do is to make the selector a class that you change when needed.

$(document).ready( function() {
    $('document').delegate( 'a.clickable', 'click' function(){return false;} ); 
});

Just remove the clickable class to disable for an element, and add it back in to enable.

No need to repeatedly unbind/bind the delegate handler.


Need Your Help

Dynamic GUI in Python?

python dynamic user-interface

I had a question about whether it would be possible to make something like the following in Python:

RewriteRule from Main Page

.htaccess url-rewriting mediawiki

Please help with setting/config of .htaccess file.