JQuery Mobile's callback on 'navigate' not executing

爷,独闯天下 提交于 2019-12-13 04:39:01

问题


I'm having a simple html page, which registers a listener on navigate that's there from JQuery-Mobile. But I can't see the callback getting executed.

The following is the html

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
        <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
        <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
    </head>
    <body>
        something
        <script>
            $( window ).on('navigate', function( event, data ){
                if ( data.state.direction == "back" ) {
                    console.log('back button pressed');
                }
                if ( data.state.direction == "forward" ) {
                    console.log('fwd button pressed');
                }
            });
        </script>
    </body>
</html>

PS: from here I got to know that JQuery mobile don't support JQuery 3.x, so I changed it to 1.x, but still this don't help.

Whenever I press the back button (when I'm on the above html page), I suppose I should get `` on the console. But that's not happening. Is there anything obvious that I'm missing?

来源:https://stackoverflow.com/questions/57372803/jquery-mobiles-callback-on-navigate-not-executing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!