Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allow propagation again

Tags:

jquery

I disable propagation of clicks.

$(document).ready(function () {
            $('#user-wrapper .dropdown-menu').click(function (e) {
                e.stopPropagation();
            });
        });

How can I enable it again?

Let's say I'd like to have 2 functions: stopPropagation() and enablePropagation()

like image 246
Amio.io Avatar asked Jul 26 '26 06:07

Amio.io


1 Answers

Once propagation has been stopped, it cannot be resumed. As a workaround, what you can do is set a variable, and then only stop if this variable is true:

var stop = false;
// do your logic here
if(stop){
    event.stopPropagation();
}

Solution #2

Or you may try this in another way

$('#some_link').click(function(event){
    event.preventDefault();
});

$('#some_link').unbind('click'); //worked as the only method to restore the default action.

Your call!

Hope it helps.

like image 73
Toan Nguyen Avatar answered Jul 27 '26 20:07

Toan Nguyen