user3376065
user3376065

Reputation: 1187

How to undo .click(false)

I have a page transition which uses jQuery animate. I found that the following code:

$("body").click(false); 

is the best way to stop any mouse clicks on the page while the animation is running. But I'm not sure how to undo it! Any ideas?

Upvotes: 1

Views: 132

Answers (3)

vick
vick

Reputation: 476

show me the animation code snippet. You should place $("body").unbind("click"); in the callback of the animation function. When it's done animating, it will unbind the click again.

Upvotes: 0

Milind Anantwar
Milind Anantwar

Reputation: 82251

You can check for :animated length on body click.try this:

$('body').click(function () {
if ($(':animated').length) {
    return false;
  }
});

Upvotes: 2

jacobappleton
jacobappleton

Reputation: 538

Try using .unbind()

$("body").unbind("click");

Upvotes: 3

Related Questions