javascript - 事件触发时,PhoneGap 和 OnsenUI 模式不显示

标签 javascript angularjs cordova phonegap-build onsen-ui

我有一个应用程序,我可以在其中单击列表项并对它们执行操作。单击事件会弹出一个对话框,询问用户是否确定是否要执行操作。 单击“确定”后,模式应显示一个旋转齿轮图标,并在一切完成后消失。

如果我在浏览器中尝试它,它会完美地工作,但我的 iPhone 或 Android 上的 PhoneGap 模拟器不会显示它。

我的index.html 文件中有以下模式:

<ons-modal var="modal_update">
    <ons-icon size="35px" spin="true" icon="ion-load-d"></ons-icon>
    <br><br>
    Please wait
    <br>Updating data on the server...
</ons-modal>

我有一个点击事件,它会弹出一个温泉对话框,其中包含“确定”和“取消”作为可能的答案。 如果用户单击“确定”,模式应该显示,并且当一切完成后它应该隐藏。列表项旁边还有一个图标,它应该变成一个旋转齿轮...

所以我有以下代码:

$scope.confirm = function(item, id) {
    ons.notification.confirm({
        title:"",
        message: "Do you want to set this task to completed?",
        callback: function(idx) {
            switch(idx) {
                case 0: //if they hit CANEL
                    break;
                case 1: //if they hit OK
                    modal_update.show();
                    //PROCESSING DATA
                    //do things with the data
                    //Change icon to rotating gear 
                    //$scope.apply - i tried with and without this, nothing helped.
                    modal.hide();
                    break;
             }
         }
     });
 }

模态 .show() 和 .hide() 在其他地方工作,例如“下拉刷新”。

最佳答案

我看到的唯一问题是您没有使用 $scope 访问模式,而是使用 modal.hide() 而不是 modal_update .hide():

case 1: //if they hit OK
    $scope.modal_update.show();
    //PROCESSING DATA
    //do things with the data
    $scope.modal_update.hide();
    break;

它在这个 Codepen 中工作(我刚刚添加了一个超时来查看模式):http://codepen.io/frankdiox/pen/KdzwGR

希望对你有帮助!

关于javascript - 事件触发时,PhoneGap 和 OnsenUI 模式不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32607927/

相关文章:

javascript - 同位素和 DOM 顺序

javascript - Cordova PDFkit blob 流到 IPP 打印机?

javascript - 如何在 Angular Controller 中使用按其属性过滤的对象?

javascript - 关闭使用 Angularjs 制作的 Android 应用程序中的子窗口

ios - 未在iOS商店中上传phonegap应用

javascript - EditorJs 警告 "«blocks.stretchBlock()» is deprecated and will be removed in the next major release. Please use the «BlockAPI» instead."

javascript - 当部分不是全高时垂直固定导航

javascript - 创建带有按钮的标签文本字段

javascript - Angularjs $http 在 IE9 中从本地磁盘加载数据问题

javascript - 在 Ionic 应用程序上使用 $.getScript 加载 Google Map Api