vaidik / jquery-longpress

A jQuery plugin that makes it easy to support long press events on mobile devices and desktop borwsers.
64 stars 23 forks source link

Delegate longpress #3

Open timovanderzanden opened 10 years ago

timovanderzanden commented 10 years ago

Currently there doesn't seem to be a way to delegate the longpress, so it doesn't work when binding future elements.

As a temporary workaround I have added a selector variable to the function. So my event handlers are as follow:

$this.on('mousedown', selector, mousedown_callback);
$this.on('mouseup', selector, mouseup_callback);
$this.on('mousemove', selector, move_callback);

Where $this refers to a parent object or document and selector to the pressable element itself. This works, but I don't know if this would be the best approach.

PS. Thank you for the mousemove fix!