peter
peter

Reputation: 13491

Why is my Phonegap Button Not Responsive

I am using phonegap like this in my application, also note the app is being styled by jquery mobile,

    <meta name="viewport" content="width=device-width, initial-scale=1"> 

    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />

    <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="phonegap-1.3.0.js"></script>

I have this html,

<div id="sync" data-role="page">
    <div data-role="header" data-position="inline">
        <a data-rel="back" data-icon="back">Back</a>
        <h1>Sync</h1>
    </div>
    <div data-role="content">
        <button onclick="sync()">Sync</a></button>
    </div>  
</div>

I have compiled this for Android and have it working on my Android phone.

But the button there called 'sync' is not always responsive. I click the button and the sync() method doesn't get called every time. I find myself clicking the button a number of times. I can see the button moving when I click it, it is responding by drawing itself being pushed in, but the sync method is not being called.

The sync method starts like this,

function sync()
{
    alert("syncing");
    $.mobile.loadingMessage = "syncing";
    $.mobile.showPageLoadingMsg();

I put the alert in for debugging purposes.

UPDATE:

It has been pointed out that my HTML has an extra tag in it. I have removed it as below but the problem still exists,

<div data-role="content">
    <button onclick="sync()">Sync</button>
</div> 

Upvotes: 1

Views: 2006

Answers (2)

matt.mercieca
matt.mercieca

Reputation: 873

I had a similar problem in my application. I tried two different things but I'm not sure wich fixed it.

  1. I added charset="utf-8" in my script tag.

  2. I moved the button click function in to its own script tag. I think there's an error in the other JavaScript block that is preventing the button click function from working when it's in that script block. So you can try isolating the button click JavaScript and see if that helps.

Upvotes: 2

Marc B
Marc B

Reputation: 360662

Joke answer: did you push the button hard enough?

Possibly the problem answer:

    <button onclick="sync()">Sync</a></button>
                                 ^^^^---dangling tag

Is that </a> possibly the cause of the button breaking?

Upvotes: 1

Related Questions