我有一个表单,用户在其中输入了一些信息。单击提交按钮后,脚本会检查条目。如果出现问题,用户必须返回并修复它。
但是当我使用时history.back()
,页面将被重新加载并且所有条目都消失了。我怎样才能使它与 jQuery Mobile 一起工作?
<a href="javascript:history.back()" data-icon="back" data-role="button" data-theme="b">Back</a>
我有一个表单,用户在其中输入了一些信息。单击提交按钮后,脚本会检查条目。如果出现问题,用户必须返回并修复它。
但是当我使用时history.back()
,页面将被重新加载并且所有条目都消失了。我怎样才能使它与 jQuery Mobile 一起工作?
<a href="javascript:history.back()" data-icon="back" data-role="button" data-theme="b">Back</a>
Simply try this
javascript:history.go(-1)
This is worth reading to... https://developer.mozilla.org/en-US/docs/DOM/Manipulating_the_browser_history
These are Plugins..If You don't want to add plugins then avoid it..but it works great and servers the purpose.
http://benalman.com/projects/jquery-bbq-plugin/
https://github.com/browserstate/history.js
In any case you will have to add some logic to make the data persist in some state or session to use it when you come back.
Jquery Mobile Specific solution:
data-rel="back" on anchor tag.
http://jquerymobile.com/demos/1.0a4.1/#docs/forms/../../docs/content/../../docs/forms/../../docs/forms/../../docs/pages/docs-pages.html See Back Linking in JQuery Mobile.