1

I'm writing a phonegap app and am using jquery mobile for the front end. I have a form which has 4 fields and a link, the link goes to another page that displays a listview of possible values for one of the fields, which on tap/click returns to the original form and populates one of the fields with the passed value.

The problem is that any fields the user completed prior to using the find link are now empty (because the page has been loaded again).

I know I could pass the field values between the 2 pages or use a few global variables but I wondered if there was any JQM specific way of doing this (or any cleaner way anyone could recommend).

Thanks in advance

Jimothey
  • 2,414
  • 9
  • 41
  • 66

2 Answers2

2

There are few possible ways and you can find them in my other ARTICLE, let me be transparent, it is my personal blog. Or you can find it HERE, no point in repeating them here. You will also find examples there plus good/bad sides of every approach.

Basically it all depends are you using 1 HTML / multiple pages template or multiple HTML files to create you jQuery Mobile application.

Look for chapter: Data/Parameters manipulation between page transitions.

Community
  • 1
  • 1
Gajotres
  • 57,309
  • 16
  • 102
  • 130
  • Thanks I'll check it out, I should have said - I'm using single page templates (one .html file for each view). – Jimothey Feb 20 '13 at 16:09
  • 1
    Marked as correct due to your awesome link that addresses some other issues I'm having. Hats off to you sir ;) – Jimothey Feb 20 '13 at 16:36
1

You could use localStorage which I beleive PhoneGap supports - http://docs.phonegap.com/en/1.2.0/phonegap_storage_storage.md.html#localStorage

Just dump your values into storage before navigating off the page and reload them when you come back.

Lloyd
  • 29,197
  • 4
  • 84
  • 98