Javascript JQuery移动更改页面第一次后退

Javascript JQuery移动更改页面第一次后退,javascript,jquery,html,jquery-mobile,web,Javascript,Jquery,Html,Jquery Mobile,Web,当我初始化一个页面并尝试导航时,第一次页面后退。为什么页面会后退 我尝试这样导航:$.mobile.changePage(“#pagename”) 比如说。我试着在初始化后从主界面转到客户页面,我点击图标。导航完成后,网页将进行导航。网页将返回导航,但就在第一次返回时,url仍然是#… 代码: 奥达尔 客户 历法 谈判 asdf 注销 Ügyféltörzs g_loginViewModel=null; m_tokenKey=“令牌”; m_服务器名=”http://localhost:496

当我初始化一个页面并尝试导航时,第一次页面后退。为什么页面会后退

我尝试这样导航:
$.mobile.changePage(“#pagename”)

比如说。我试着在初始化后从主界面转到客户页面,我点击图标。导航完成后,网页将进行导航。网页将返回导航,但就在第一次返回时,url仍然是
#…

代码:


奥达尔
客户
历法
谈判
asdf
注销
Ügyféltörzs
g_loginViewModel=null;
m_tokenKey=“令牌”;
m_服务器名=”http://localhost:49670";
$(函数(){
$.mobile.ignoreContentEnabled=true;
if(window.localStorage.getItem(m_tokenKey)!=null){
$.mobile.changePage(“主页”);
//bootstrap();
}否则{
g_loginViewModel=新的loginViewModel();
应用绑定(g_loginViewModel,document.getElementById(“登录页面”);
}
});

请用小提琴把它贴出来,你说的页面后退是什么意思?我想您不需要将第一页指定为更改页,它应该直接加载第一页的数据角色页。

您找到解决方案了吗,因为我也有同样的问题:(所以我解决了这个问题。我设置了$.mobile.autoInitialize=false;而不是$.mobile.initializePage();但是这个函数造成了问题,所以我删除了$.mobile.initializePage();并将autoInitialize设置为true(dafault选项)。这对我有效,但对于您的代码我不知道。。。
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <link rel="stylesheet" href="styles/jquery.mobile-1.3.1.min.css" />
    </head>

    <body>

        <!-- //////////////////////////////////////////////////////
        //////////          MAIN PAGE          ///////////////
        ////////////////////////////////////////////////////// -->
        <section id="main-page" data-role="page" data-fullscreen="true">
            <header data-role="header">
                <h1>Főoldal</h1>
            </header>
            <div data-role="content">
                <table>
                    <tbody>
                        <tr>
                            <td>
                            <div class="metro-bt" onclick="$.mobile.changePage('#customer-page');" id="customer-btn"> <!-- <<<-------------- here I invoke the function change page and than change back, but just at the first time -->
                                <div></div>
                                <span>Customers</span>
                            </div></td>
                            <td>
                            <div class="metro-bt" data-bind="click: bt_calendar_click" id="calendar-btn">
                                <div></div>
                                <span>Calendar</span>
                            </div></td>
                        </tr>
                        <tr>
                            <td>
                            <div class="metro-bt" data-bind="click: bt_negotiation_click, enable:isNegBtEnable" id="negotiation-btn">
                                <div></div>
                                <span>Negotiation</span>
                                <span data-bind="text: durationOfNegotiation" style="line-height: 0; display: block;"></span>
                                <span data-bind="text: nameOfPartner" style="line-height: 15px;clear: both; display: block;">asdf</span>
                            </div></td>
                            <td>
                            <div class="metro-bt" data-bind="click: bt_logout_click " id="logout-btn">
                                <div></div>
                                <span>Logout</span>
                            </div></td>
                        </tr>
                    </tbody>
                </table>

            </div>
        </section>

        <!-- //////////////////////////////////////////////////////
        //////////          Customer            ///////////////
        ////////////////////////////////////////////////////// -->

        <section id="customer-page" data-role="page" data-fullscreen="true">
            <header data-role="header">
                <h1>Ügyféltörzs</h1>
                <a data-role="button"  href="#main-page" data-icon="back" data-iconpos="notext" class="ui-btn-left"></a>
            </header>
            <div class="content" data-role="content">
                <div data-enhance="false" data-bind="event: { rowselect: rowselect }" id="customer-jqxGrid" style="margin: 0 auto"></div>
            </div>

            <div data-role="footer" data-position="fixed" data-tap-toggle="false">
                <a href="#add_customer-page" data-icon="plus"> Hozzáad </a>
                <a id="b-customer-negotation" class = "ui-disabled" data-icon="star" data-bind="click: startNegotiation">  </a>
                <a id="b-customer-modify" class = "ui-disabled" data-icon="edit" data-bind="click: modify"></a>
            </div>
        </section>



        <link rel="stylesheet" href="styles/jqx.base.css" type="text/css" />
        <link rel="stylesheet" href="styles/main.css" type="text/css" />

        <script type="text/javascript" src="scripts/lib/jquery-1.9.1.min.js"></script>
        <script src="scripts/lib/knockout-2.2.1.js"></script>


        <script src="scripts/lib/jquery.mobile-1.3.1.min.js"></script>



        <script type="text/javascript">
            g_loginViewModel = null;
            m_tokenKey = "token";
            m_serverName = "http://localhost:49670";

            $(function() {
                $.mobile.ignoreContentEnabled = true;
                if (window.localStorage.getItem(m_tokenKey) != null) {
                    $.mobile.changePage("#main-page");
                    // bootstrap();
                } else {
                    g_loginViewModel = new LoginViewModel();
                    ko.applyBindings(g_loginViewModel, document.getElementById("login-page"));
                }
            });

        </script>
    </body>
</html>