问题
I developed a mobile application using jquery mobile. On a particular page I try to call a javascript function via a "onclick" on a button.
All works perfect in Safari on the iPhone when hosted online. http://laughlouder.onesixtydev.nl/star/batna.html
But when I build the app via PhoneGap build (online), the button is frozen. Im not sure if PhoneGap build of the app uses the same Safari browser for this web view. But what ever I try, the link wont work.
Tried this:
<input type="button" value="Save" onclick="doSetItem();" data-ajax="false">
And this:
<a href="#" data-role="button" onclick"doSetItem();">
Strange thing that is works in Safari, but not via PhoneGap build. What is the difference anyway?
Tried putting the function in document ready, or loading it via onload in the body all does not make a difference. Googling for days now, and nobody seems to have the same problem.
Who can help? Thanks a lot.
回答1:
you should use tap event instead of click.
<a href="#" data-role="button" ontap"doSetItem();">
http://digitalize.ca/2010/02/jqtouch-tap-vs-click/
http://www.bagonca.com/blog/2010/06/18/use-tap-events-instead-of-click-events-in-iphone-browser/
来源:https://stackoverflow.com/questions/9956014/phonegap-build-jquerymobile-onclick-on-button-does-not-work