Book Image

PhoneGap 4 Mobile Application Development Cookbook

Book Image

PhoneGap 4 Mobile Application Development Cookbook

Overview of this book

Table of Contents (19 chapters)
PhoneGap 4 Mobile Application Development Cookbook
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

Persisting data between jQuery Mobile pages


In this recipe, we will build upon the podcast application built in the previous recipe, extending the functionality and features available for the user.

So far, our podcast application consists of a few simple pages that are independent of each other; that is, any content consumed by a page is used by that page only.

How to do it...

We will use the localStorage capabilities to save and retrieve information, causing it to persist across pages:

  1. With the list now populated, we need to revise the home method to include a function to capture the tap events on each list item. This will obtain the title, enclosure, and description attribute values from the selected item and set them in the localStorage on the device so that we can cause them to persist on the next screen. Then we'll force a page change to a new page called itemdetail:

    $("#home").bind("pagecreate", function(e) {
        getRemoteFeed();
        $('#showList').on('click', 'li', function() {
          ...