Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have a mastercheckbox in my jqgrid header

<input type="checkbox" id="masterCheckBox"  ondblclick="onDoubleClick(event,assetSearchResults,this)" onclick="masterCheckBoxChecked(event,assetSearchResults,this)"/>

When I put only onclick or ondblclick, corresponding method is getting called. But when I have both onclick and ondblclick, only onclick method will be called. I can't even double click the checkbox. How to handle both onclick and ondblclick for single checkbox?

Below are the methods for singleclick and doubleclick. I have given timeout also. But I am unable to catch doubleclick event.

var timer=;
    function onDoubleClick(e,table,obj){
            clearTimeout(timer);
            alert('Double click');
            function masterCheckBoxChecked(e,table,obj){
                 document.getElementById("masterCheckBox").checked=true;
                 if (timer) clearTimeout(timer);
                 timer = setTimeout(function() { alert('Single'); }, 150);   
                 alert(timer);
                then set a variable and open popup by this variable like   if you click set it 1 and check variable value  if ===1 then open popup first and when click again it will incrment by 1 then check if===2 then show second popup  and then reset variable
– Rituraj ratan
                Oct 15, 2013 at 11:12
  

It is inadvisable to bind handlers to both the click and dblclick events for the same element. The sequence of events triggered varies from browser to browser, with some receiving two click events before the dblclick and others only one. Double-click sensitivity (maximum time between clicks that is detected as a double click) can vary by operating system and browser, and is often user-configurable.

jQuery reference: http://api.jquery.com/dblclick/

So I think it's better if you reconsider your actual UI using only one click event and other controls to handle your needs; eg on the click handler open a menu with the possible actions.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.