当原型在外面使用$时,如何在domready中使用$ for jQuery? [英] How to use $ for jQuery inside domready when prototype is using $ outside?

查看:91
本文介绍了当原型在外面使用$时,如何在domready中使用$ for jQuery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法从JSF框架中删除原型(RichFaces 3.3.3)。如果我尝试noConflict并尝试接管$,它会破坏我的应用程序框架,因为它与原型紧密结合。

I'm unable to remove prototype from a JSF framework (RichFaces 3.3.3). And if I try noConflict and try to take over $ it breaks my application framework because its tightly coupled with prototype.

所以有一种方法可以做到这一点:

So is there a way that I can do this:

jQuery(function() {
    /*
        some code that within this domready function 
        allows me to use $() within this function
        and not interfere with $ being used for prototype
        outside?
    */
});


推荐答案

是的,它已作为第一个参数传入你的 ready 处理程序,只需使用:

Yes, it's already passed in as the first parameter to your ready handler, just use:

jQuery(function($) { 
  $("selector").doSomething();
});
//$ is still prototype here

这篇关于当原型在外面使用$时,如何在domready中使用$ for jQuery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆