Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Cannot Reproduce
-
cordova-cli@6.4.0
-
None
-
None
-
OS: Ubuntu_16_LTS x86_64, Kernel Version: 4.4.0-31-generic, Browser: Google Chrome 54.0.2840.71 (stable), Framework: MobileFirst 8
Description
Since the buttonIndex should return an integer, the following code should be working but the default case is always fired:
navigator.notification.confirm("Description", function (buttonIndex) { switch(buttonIndex){ case:1 //do something break; default: //do something } } }, "Title", ["OK", "Cancel"]);
A little inspection reveal that the confirm method is returning a boolean instead of a number. The following code is working:
navigator.notification.confirm("Description", function (buttonIndex) { if(buttonIndex){ //do something }else{ //do something } } }, "Title", ["OK", "Cancel"]);
The documentation states "The callback takes the argument buttonIndex (Number), which is the index of the pressed button. Note that the index uses one-based indexing, so the value is 1, 2, 3, etc." and it should be changed accordingly.