PhoneGap build + jquerymobile: onclick on button does not work

白昼怎懂夜的黑 提交于 2019-12-13 14:19:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!