RamonSmit / Nestable2

New pickup of Nestable!
Other
322 stars 147 forks source link

How do I trigger a double click event on an element? #83

Closed s1lver closed 7 years ago

s1lver commented 7 years ago
$('.dblclick').dblclick(function () {
    console.log($(this));
  });

This code does not work...

RamonSmit commented 7 years ago

Is it a dynamic created element? If so:

Try:

$(document).on('dblclick', '.dblclick',function () {
    console.log($(this));
  });

(Not sure if the syntax is correct, cannot check it at this point now but please try)

s1lver commented 7 years ago

So, I already tried. But there is no effect

RamonSmit commented 7 years ago

In that case I'm going to ask @pjona if he can take a little sneekpeek in here

s1lver commented 7 years ago

If you use unbind (), then the whole list breaks down

$(document).unbind().on('dblclick', ".dblclick", function() {
    console.log('Dblclick');
  });
s1lver commented 7 years ago

https://jsfiddle.net/4vogfw6o/2/

Dblclick on the 16 item

s1lver commented 7 years ago

Hi! The problem is solved by setting the timeouts.