Reputation: 13
I'm using the Phonegap 'confirm' in iOS.
When to use 'confirm', two buttons shown, but to be working only 1 button.
[Yes, No] button.
if the 'Yes' button is pressed only 'callback' function is activated and
'No' button nothing happens..
What should I do?
My Code>>
video.addEventlistener("ended",function(){
console.log('onended');
navigator.notification.confirm(
'Exit?',
onConfirm,
'Done',
['Yes','No']
);
}, false);
function onConfirm(button){
console.log(button);
if(button == 1){
location.href = history.go(-1);
}else if(button == 2){
...
}
}
if I clicked Yes button, log displayed 1.
if I clicked No button, log not displayed nothing.
Phonegap 2.9.1 version
I had to use 'string' on button name. but deprecated happens. solved to use 'array'
Upvotes: 0
Views: 350
Reputation: 14118
Try
function onConfirm(buttonIndex) {
alert('You selected button ' + buttonIndex);
}
This way, try getting index of both button (Yes and No) and accordingly you can define your conditional logic.
Upvotes: 1
Reputation: 421
Are you testing this on a real device? I always have trouble emulating iOS devices, because the application stops working after only one interaction. What happens if you press 'No' first?
Upvotes: 0