jquerymobile phonegap back按钮获取先前状态
I'm building an little mobile app and I got a question about JQM.
我正在开发一个移动应用程序,我有一个关于JQM的问题。
When the user is logged in the user will be redirected to page A. Page A is loaded with the loadPage from JQM (example: $.mobile.loadPage("pageA.html")
)
当用户登录时,将被重定向到A页。页面A装载了来自JQM的loadPage(例如:$. mobiley .loadPage(“page .html”))
After the page is loaded, I do an AJAX-call because I pull some data from a database and change the content on page A. From page A, I can go to page B. page B has an back-button. When I click on the back-button, the app slides back to the state without the AJAX content. Is there a way to fix this?
加载页面后,我进行ajax调用,因为我从数据库中提取一些数据,并更改页面a上的内容。当我单击back按钮时,应用程序就会滑回到没有AJAX内容的状态。有办法解决这个问题吗?
Thanks
谢谢
1 个解决方案
#1
7
By default, jQuery Mobile will remove any page brought into the DOM via AJAX once the user navigates away from the page. If you want to disable this feature for a specific page you can add the data-dom-cache
attribute to the data-role="page
element for the page and set it to true
:
默认情况下,jQuery Mobile将在用户离开页面后,通过AJAX删除任何进入DOM的页面。如果您想要禁用特定页面的此特性,可以将data-dom-cache属性添加到页面的data-role="page element,并将其设置为true:
<div data-dom-cache="true" data-role="page" id="pageA">
...
</div>
Source: http://jquerymobile.com/demos/1.1.0-rc.1/docs/pages/page-cache.html
来源:http://jquerymobile.com/demos/1.1.0-rc.1/docs/pages/page-cache.html
This feature was added to jQuery Mobile to help control the size of the DOM so less browser crashes will occur. If you just want to keep a single page in the DOM then make sure it's not a huge page that will bog-down the device.
这个特性被添加到jQuery Mobile以帮助控制DOM的大小,从而减少浏览器崩溃的发生。如果您只想在DOM中保留一个页面,那么请确保它不是一个会使设备陷入困境的大页面。
更多相关文章
- jquery 触发a标签点击事件,弹出页面
- 如何在jQuery Datatables分页中返回特定页面?
- jQuery File Upload 单页面多实例的实现
- 如何使用CSS将表放在页面的中心?
- 如何在HTML中为移动页面创建图像下载链接?
- html 页面内锚点定位及跳转方法总结
- xml格式原样输出到html或是jsp页面
- HTML5-Service Worker实现离线页面访问
- Html5如何使我们开发出来的应用或页面大小能适合各种高端手机使