I have the following JS for a doubletap event on the element '.snap_img' with the Hammer.js JQuery plugin.
$("body").hammer().on('doubletap','.snap_img',function() {
img_src = (this).getAttribute('src');
alert(img_src);
return false;
});
The element '.snap_img' is created dynamically by an AJAX post() request. Therefore, I need event delegation to be able to fire the Hammer event. This JS is based on this piece of code which successfully fires a click event on the dynamically loaded .snap_img elements:
$("body").on('click','.snap_img',function() {
img_src = (this).getAttribute('src');
alert(img_src);
return false;
});
How do I make the code with the Hammer JQuery plugin work? I suppose the solution should be very similar to the second piece of code in this question, but I can't seem to figure it out.
If you are using
Hammer
, you can try something like this: