Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  9] [ 5]  / answers: 1 / hits: 20823  / 13 Years ago, thu, february 16, 2012, 12:00:00

I am attempting to use the jQuery mobile events without the rest of jQuery mobile.



https://github.com/jvduf/jquery-mobile-events/blob/master/jquery.mobile.events.js



That snippet enables them all, and works fine, but not with the .on() event handler. E.g:



$('a').on('tap',function(){
console.log('Hi there!');
});


However it does work with .live(), but that is now depreciated.



So my question; is there a a way to extend the .on() functionality to include the tap event and others? Full list below:




  • touchstart

  • touchmove

  • touchend

  • orientationchange

  • tap

  • taphold

  • swipe

  • swipeleft

  • swiperight

  • scrollstart

  • scrollstop



Thanks :)


More From » jquery

 Answers
11

However it does work with .live(), but that is now depreciated.




So I take it that you want to use event delegation to preserve those events on replaced elements. That would mean that this:



$('a').on('tap',function () {
console.log('Hi there!');
});


would need to change to something like:



$(document).on('tap', 'a', function () {
console.log('Hi there!');
});


in order for it to behave the same as $(a).live(tap, ...


[#87427] Wednesday, February 15, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
andreguym

Total Points: 125
Total Questions: 112
Total Answers: 103

Location: Wallis and Futuna
Member since Tue, Mar 30, 2021
3 Years ago
;