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 i开发者_JAVA技巧s 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.
精彩评论