简体   繁体   中英

jQTouch with PhoneGap on webOS

I'm writing an application in PhoneGap that I want to run on iOS, Android, and webOS. jQTouch plays nice with everything on iOS and Android, but not webOS.

Since the webOS Mojo framework is based on Prototype (which uses the $ variable), it's necessary to use jQuery in noConflict mode. I can handle that much.

However, the problem is that I also want to use the jQTouch plugin. The jqtouch.js file uses $ throughout, causing JavaScript errors when that file is loaded.

Is there a way to run the jQTouch plugin (or any plugin for that matter) in my PhoneGap application without interfering with Prototype?

You should be able to wrap it in a closure and pass jQuery in. For example:

(function($){
   alert($);
}("Hello"))

(function($){
   $("foo"); // uses the jQuery rather than $
}(jQuery))

actualy you can get rid of prototyper so there is no conflict. read this exerpt from one of their programming guides:

Mojo is the standard JavaScript framework that most webOS apps are built with. However, if you aren't using any features within it then it's just costing you startup time. You can prevent Mojo from loading by just commenting out the script tag at the top of your index.html page.

--> Mojo does one thing that we need however. It tells the window manager when the app is fully loaded and ready to go. We can do this manually with a simple onLoad event handler. Add the following script to the head of the index.html page:

function onLoad() { if (window.PalmSystem) { window.PalmSystem.stageReady(); } }

Then add a call in the body's onload event.

That's it! Now the app will load without Mojo and start up much more quickly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM