Reputation: 559
I have 2 pages in jquery mobile which contains form and select elements, and the values are submitted in second page form submit button.
Here, my question is, If i click on the 2nd page back button, previously entered/selected values of first page will be shown.
How do we achieve that without using local storage? Is there any possible way in jquery mobile itself.
Thanks in advance...
Upvotes: 0
Views: 150
Reputation: 895
If you navigate from one html file to another, I don't think there is a simple way except local storage or similar API, or cookies.
If you don't want to use one of these especially because the data stay stored even after you leave the page, think about having multiple pages in html document and submitting the form using ajax instead and after the data are submitted, changing the page programatically using $.mobile.changePage("#resultPage");
There is a plugin for submitting the form using ajax here: http://jquery.malsup.com/form/
Then it shoud be easy to pick the data from a local variable.
Edit:
Check the answer here. There is apparently a way how to store data unique for a particular browser window (so it does not remain stored after you leave). But I guess doing things the recommended way is usually best thing to do.
can JavaScript store data unique to a particular browser window instance?
Upvotes: 1
Reputation: 6648
Look at http://nadh.in/code/localstoragedb/
localStorageDB is a simple layer over localStorage that provides a set of functions to store structured data like databases and tables. It provides basic insert/update/delete/query capabilities. localStorageDB has no dependencies, and is not based on WebSQL. Underneath it all, the structured data is stored as serialized JSON in localStorage.
Data creating, manipulating, deleing, Querying etc. are very easy and its coding is pure JQuery.
Taken from: Using Local Database w/ JQuery Mobile?
You can also use cookies, eventhough it's a bad method. Sorry for making this as an answer. I can't comment, so I have to write answers.
Upvotes: 0