我有#P1,P2#,#P3多页表格。 当我提交表单,当我尝试单击后退浏览器按钮,它应该去#p1和空表单字段。 有可能wiith jQuery Mobile的?
Answer 1:
我想重写后退按钮并为您的页面是活动页面,然后根据页面上的作事房子打扫你需要...
我提交了一个例子来真的类似于这样一个问题:
后退按钮处理程序
在那里我有选项,弹出菜单和主页,你可能只需要P3当activePage等于P3明确您的形式和节目P1。
function pageinit() {
document.addEventListener("deviceready", deviceInfo, true);
}
function deviceInfo() {
document.addEventListener("backbutton", onBackButton, true);
}
function onBackButton(e) {
try{
var activePage = $.mobile.activePage.attr('id');
if(activePage == 'P3'){
clearForm(); // <-- Calls your function to clear the form...
window.location.href='index.html#P1';
} else if(activePage == 'P1'){
function checkButtonSelection(iValue){
if (iValue == 2){
navigator.app.exitApp();
}
}
e.preventDefault();
navigator.notification.confirm(
"Are you sure you want to EXIT the program?",
checkButtonSelection,
'EXIT APP:',
'Cancel,OK');
} else {
navigator.app.backHistory();
}
} catch(e){ console.log('Exception: '+e,3); }
}
文章来源: jquery mobile, browser back button navigation