JQM and Phonegap. No alert on button click.

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:

  1. $(document).ready(function() {
  2.    $("#startnewbtn").click(function() {
  3.       alert('click');
  4.       navigator.notification.alert( 'inception' , null , 'Info' , 'OK' ) ;
  5.       alert('post click');
  6.    }
  7. }

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:

  1. document.addEventListener("deviceready", function f() {
  2.    $("#startnewbtn").click(function() {
  3.        navigator.notification.alert( 'inception' , null , 'Info' , 'OK' ) ;
  4.    }
  5. }, false );