Jimothey
Jimothey

Reputation: 2434

Keeping form values when navigating between pages

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

Upvotes: 1

Views: 1089

Answers (2)

Gajotres
Gajotres

Reputation: 57309

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.

Upvotes: 2

Lloyd
Lloyd

Reputation: 29668

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.

Upvotes: 1

Related Questions