Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Duplicate
-
3.5.0
-
None
-
None
Description
Hi,
I'm creating a multiple pages project with Phonegap. My project contains the page index.html and connection.html.
Both pages contain a listener for the Back button on Android :
document.addEventListener("backbutton", onBackKeyDown, false);
When I press the Back button, it shows a confirmation dialog that asks me if I really want to quit the app :
function onBackKeyDown()
{
console.log('onBackKeyDown beginning');
navigator.notification.confirm(
'Do you really want to exit the app?',
onConfirm,
'Avertissement',
["No", "Yes"]
);
console.log('onBackKeyDown end');
}
function onConfirm(button)
{
console.log(button);
if(button == 2)
navigator.app.exitApp();
}
If I click on a link (<a href="connection.html">connection</a>) in the index.html page to get to the page connection.html, everything goes fine.
My problem is that when I get to the page connection.html by a JS redirection (window.location.href='connection.html'), it creates a delay in the callback of the notification.confirm.
By using window.location.href, this is what will happen :
1. I click the Back button in the connection.html page
2. console.log : onBackKeyDown beginning
3. The confirmation dialog appears
4. console.log : onBackKeyDown end
5. I click No
6. I click the Back button again
7. console.log : onBackKeyDown beginning
8. the confirmaiton dialog appears
9. console.log : onBackKeyDown end
10. console.log : 1 (It shows the log of my previous click)
What I want to happen :
1. I click the back button in the connexion.html page
2. console.log : onBackKeyDown beginning
3. The confirmation dialog appears
4. console.log : onBackKeyDown end
5. I click No
6. console.log : 1 (the button I pressed)
Am I missing something? What do I need to do to make it work normally ?
Thanks.
Attachments
Issue Links
- duplicates
-
CB-6761 Calling a function the first time no callbacks are being executed
- Closed