【问题标题】:Determine if back button clicked in Kendo Mobile view?确定是否在 Kendo Mobile 视图中单击了后退按钮?
【发布时间】:2013-08-28 06:37:14
【问题描述】:

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

这是我尝试在其中进行的视图展示:

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

【问题讨论】:

    标签: javascript jquery kendo-ui kendo-mobile


    【解决方案1】:

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

    /*
    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;
    
    }
    

    【讨论】:

    • 我还能够找到一个可以使用的私有财产,但不确定依靠它有多可靠:e.view._back
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-29
    • 1970-01-01
    相关资源
    最近更新 更多