webOS 上的 jQTouch 与 PhoneGap

发布于 2024-09-05 08:46:22 字数 473 浏览 1 评论 0原文

我正在 PhoneGap 中编写一个应用程序,我想在 iOS、Android 和 webOS 上运行。 jQTouch 可以很好地兼容 iOS 和 Android 上的所有内容,但不能兼容 webOS。

由于 webOS Mojo 框架基于 Prototype(它使用 < code>$ 变量),需要在 noConflict 模式下使用 jQuery。我能应付这么多。

然而,问题是我也想使用jQTouch插件。 jqtouch.js 文件自始至终都使用 $,因此在加载该文件时会导致 JavaScript 错误。

有没有办法在我的 PhoneGap 应用程序中运行 jQTouch 插件(或任何与此相关的插件)而不干扰 Prototype?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

手心的温暖 2024-09-12 08:46:22

您应该能够将其包装在闭包中并传入 jQuery。例如:

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

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

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))
清旖 2024-09-12 08:46:22

实际上你可以摆脱原型机,这样就不会有冲突。阅读他们的编程指南之一的摘录:

Mojo 是大多数 webOS 应用程序构建时使用的标准 JavaScript 框架。但是,如果您没有使用其中的任何功能,那么它只会浪费您的启动时间。您只需注释掉 index.html 页面顶部的脚本标记即可阻止 Mojo 加载。

-->
然而,Mojo 做了我们需要的一件事。它告诉窗口管理器应用程序何时完全加载并准备就绪。我们可以使用简单的 onLoad 事件处理程序手动完成此操作。将以下脚本添加到index.html页面的头部:

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

然后在body的onload事件中添加一个调用。

就是这样!现在,该应用程序无需 Mojo 即可加载,并且启动速度更快。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文