O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling New Mobile Events

$("#myImage").on("swipeleft", function(e) {   . . .swipe left code . . . }); $(document).on("pageLoad", function(e, data) {   . . . page load code . . . }); $(document).on("pagebeforechange", function(e, data) {   var toPage = data.toPage;   . . . page change code . . . });

One of my favorite features of jQuery Mobile is how easy it is to implement mobile events. The library automatically creates the events and adds them to elements based on the data attributes. If you want to add or remove a specific mobile event, you can do so using the .on() method from jQuery that you are already familiar with.

For example, to add a tap handler to an element #myImage, you would use the following: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required