Rick
Rick

Reputation: 17013

Javascript / Jquery, disabling all double clicks anywhere within body of web page?

I already have a lot of AJAX code written for a web app and didn't take into account the problems that double clicks on some things can cause. I already implemented an "inprogress" variable for sensitive AJAX calls so that it won't be messed up by double clicking by the user but I am wondering if there is a simple way to just disable all double clicks anywhere (in any element) within the entire body of the web page rather than having to do it individually for each specific element.

Thanks for any advice

Upvotes: 1

Views: 3859

Answers (3)

Naor
Naor

Reputation: 24053

If you havn't bound events to double click, double click will do nothing. It is event of its own.
Click and DoubleClick are different events.

Upvotes: 0

Chad
Chad

Reputation: 19609

$('*').dblclick(function(event) { event.preventDefault(); return false; });

Should handle it, however there is probably a better solution out there.

Upvotes: 3

Josh M.
Josh M.

Reputation: 27773

Try something crazy like this:

$("*").dblclick(function (event)
{
    event.preventDefault();
});

In theory, it would capture the double-click event on any element and then basically do nothing (cancels the default action).

Upvotes: 5

Related Questions