views:

419

answers:

1

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?

+2  A: 

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))
JAM