确定在Kendo Mobile视图中是否单击了后退按钮



在我看来,除非用户使用后退按钮,否则我想执行一个操作。有没有办法在视图中确定源请求是否来自后退按钮?

这是视图的show I event我正在尝试在中执行它

<div data-role="view" data-show="onShow"...>...</div>
onShow: function (e) {
  if (???) { //How to determine if user came via back button or not
    //Do something
  }
}

尝试以下代码来处理应用程序中的返回按钮。

/*
Device Back Button Handling of all html pages                      
*/
document.addEventListener("deviceready", deviceInfo, true);            
function deviceInfo() {
document.addEventListener("backbutton", onBackButton, true);
} 
function onBackButton() {
    var item = app.view().id;
        switch (item) {
                 case "index.html"
                 /*your scenario*/
                 break;
                 case "2ndpage.html"
                 /*your scenario*/
                 break;
}

最新更新