0

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

4

2 回答 2

1

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?

于 2013-07-24T11:26:03.403 回答
0

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

取自:使用带有 JQuery Mobile 的本地数据库?

您也可以使用 cookie,尽管这是一种不好的方法。很抱歉将其作为答案。我不能评论,所以我必须写答案。

于 2013-07-24T10:33:38.323 回答