简体   繁体   English

如何在phonegap应用程序中的notification.confirm()中获得单击的按钮

[英]How to get the clicked button in notification.confirm() in phonegap application

I have used the Phonegap notification.confirm as like below, 我已经使用了Phonegap notification.confirm,如下所示,

navigator.notification.confirm(
    'Do you want to continue ?',
     function() {
         console.log("Called");
     },
    'Game Over',
    'Continue,Exit'
);

How can i trace the clicked button ? 我如何跟踪单击的按钮?

When the user clicks any button, you callback function is triggered with the index of the button. 当用户单击任何按钮时,您的回调函数将通过按钮的索引触发。 You can get to check the index and proceed as per your requirement. 您可以检查索引并根据需要进行操作。

navigator.notification.confirm(
    'Do you want to continue ?',
    function(btnIndex) {
        if(!btnIndex)
            console.log("Continue");
        else
            console.log("Exit");
    },
    'Game Over',
    'Continue,Exit'
);

The value for btnIndex will be 0 - Continue , 1 - Exit . btnIndex的值将为0 - Continue1 - Exit This index is totally based on the sequence you have provided in navigator.notification.confirm . 该索引完全基于您在navigator.notification.confirm提供的顺序。

Hope this helps you. 希望这对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM