JQM and Phonegap. No alert on button click.
I'm developing an iPhone app with Phonegap 2.2.0 and JQM 1.2.0.
I want a phonegap alert to show on button click:
- $(document).ready(function() {
- $("#startnewbtn").click(function() {
- alert('click');
- navigator.notification.alert( 'inception' , null , 'Info' , 'OK' ) ;
- alert('post click');
- }
- }
When I tap the button with id="startnewbtn" the first time, 'click' will pop-up. So will 'post click' but not 'inception'. On the second tap there will be 2 or 3 'inception' pop-ups. The subsequent taps will work correctly, with one 'inception' pop-up.
What is causing the alert not to work correctly in the beginning? Is it something to do with $(document).ready() or $(#buttonid).click()?
Putting a deviceready eventListener on the document won't help:
- document.addEventListener("deviceready", function f() {
- $("#startnewbtn").click(function() {
- navigator.notification.alert( 'inception' , null , 'Info' , 'OK' ) ;
- }
- }, false );