Wednesday 13 January 2021

How to add double click event with context menu using JQuery


Description:

In this example we explain that how to add double click event on right click using JQuery. Or how to fire double click event with context menu using JQuery. Or how can I call double click event with right click context menu in Grid view or Data Table using JQuery.

As we all know because by default double click is not fire because of the it will call context menu event first and when context menu appears then it will not allow any action on data table or grid view.


To overcome this below is the JQuery code that will helpful you to display context menu and also fire double click event on Grid View using JQuery.

 

 Script:

$(document).contextmenu(makeDoubleRightClickHandler(function (e) {

       console.log("double right click" );

    }));

function makeDoubleRightClickHandler(handler) {

    var timeout = 0, clicked = false;

    return function (e) {

 

        e.preventDefault();

 

        if (clicked) {

            clearTimeout(timeout);

            clicked = false;

            return handler.apply(this, arguments);

        }

        else {

            clicked = true;

            timeout = setTimeout(function () {

                clicked = false;

            }, 300);

        }

    };

 


1 comments: