【问题标题】:phonegap + jqmobile: how to change page correctlyphonegap + jqmobile:如何正确更改页面
【发布时间】:2014-05-10 09:23:51
【问题描述】:

我正在使用 cordova + Ripple 模拟器 + jq mobile 开发 android 应用程序。我想在成功登录后更改页面。主(也是唯一)页面的 html:

 <div data-role="page" id="login">

        <div data-role="header">
            <h1>
                Вход
            </h1>
        </div>

        <div class="ui-content">
            <div id="loginFlashMsg">

            </div>

            <form id="loginFrm">
                <div>
                    <label for="loginInptTxt">Ваш логин:</label>
                    <input type="text" id="loginInptTxt" />
                </div>

                <div>
                    <label for="pswInptTxt">Пароль:</label>
                    <input type="password" id="pswInptTxt" />
                </div>

                <button id="loginBtn">
                    Войти
                </button>
            </form>
        </div>

    </div>

    <div data-role="page" id="lots">
        <div data-role="header">
            <h1>
                Лоты
            </h1>
        </div>

        <div class="ui-content">

            <ul data-role="listview" id="lotsList">

            </ul>

        </div>
    </div>

在 json 授权后我想更改页面:

App.prototype.ProcessResponse = function (response, textStatus, jqXHR) {
if (response['status'] != 'ok') {
    this.notifyAboutError(response['status']);
} else {
    switch (response['action']) {
        case 'login':
            this.user = new User($('#loginInptTxt').val(), response['sid']);
            $.mobile.changePage("#lots");
            break;
        case 'getLots':
            this.appendLots(response['lots']);
    }
}

};

但它不起作用。我知道,changePage() 已被弃用。我尝试使用

$(":mobile-pagecontainer").pagecontainer("change", "$lots");

但一切都还是一样 - 什么都没有。提取到另一个 html 页面没有效果。如何在我的 Android 应用中切换页面?

附言我能做到的最好的事情是我看到很多页面的标题和文本“正在加载”,但在第二个之后它消失了。

【问题讨论】:

    标签: javascript android jquery-mobile cordova


    【解决方案1】:
    $.mobile.changePage("#id");
    

    有效。没问题,显示的站点更改为另一个页面 ID。 如果您想要一个花哨的过渡,请使用例如

    $.mobile.changePage("#id", {transition:"slide"});
    

    像魅力一样工作 :) 当然,您也可以导航到新页面,只需使用它而不使用“#”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-24
      • 2012-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多