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: ...

Get jQuery and JavaScript Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.