How to make lightbox open on double click/tap only?

I thought I could use a code like this but it doesn’t work:

$(document).ready(() => {
  $("#lightbox-project").click((event) => {
    event.preventDefault();
    $("#lightbox-project").dblclick();
  });
});

Here is my site Read-Only: LINK
(how to share your site Read-Only link)

hi @anthonysalamin why you do not use only $("#lightbox-project").dblclick();. Is there any reason you have to cancel the click in jQuery? I was just today use it for different things but maybe MDN Doc will help but it is JS.

or

or

or

set two listeners:

  1. return on click
  2. action on dblclick

or … :person_shrugging:

EDIT: what I have now read on W3C there is this definition:

this event type MUST be dispatched after the event type click if a click and double click occur simultaneously, and after the event type mouseup otherwise.

So dblclick must be triggered after click but in your code is dblclick part of click

UI Events.

Hi @Stan ,

I did try all of the above, with no luck so far :frowning:

hi @anthonysalamin it is hard to guess and help without any context on what you are trying to achieve and what is in the code. As I have mentioned you have “double-click” INSIDE the “click” function but the documentation says it has to be triggered AFTER. That said my pure guess will be moving $("#lightbox-project").dblclick(); from click callback. Something like this.

$(document).ready(() => {
  $("#lightbox-project").click((event) => {
    event.preventDefault();
   // do stuff
  });
  $("#lightbox-project").dblclick();
});

but I’m not familiar jQuery syntax.

EDIT: Check your console for errors and then try to find answers on the internet like in StackOverflow or …