I'm playing around with hammer.js for a web app.
I can get it to work just fine, except on content loaded with ajax.
I use the hammer.js special-events plugin for jquery.
The following works fine:
$('#menu a').on("tap", function(event) {
//console.log(event);
});
But when I use the jquery delegation syntax:
$('body').on("tap", '#menu a', function(event) {
//console.log(event);
});
Nothing happens...
What is the right syntax?
Try this if you dynamically add the a
element :
$('#menu').on("tap", 'a', function(event) {
//console.log(event);
});
or this:
$('#menu').hammer().on("tap", 'a', function(event) {
//console.log(event);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With