admin管理员组文章数量:1390803
To resolve a conflict between jQuery and prototype,
is there any way other than asking jQuery to resolve via
jQuery.noConflict
and using jQuery
instead of $('code').code
;
Can't we ask prototype $
to step down and resolve.
To resolve a conflict between jQuery and prototype,
is there any way other than asking jQuery to resolve via
jQuery.noConflict
and using jQuery
instead of $('code').code
;
Can't we ask prototype $
to step down and resolve.
3 Answers
Reset to default 8You should namespace your code anyway, and jQuery gives you a good opportunity to re-claim the $
in the same step:
jQuery.noConflict();
jQuery(function ($) {
// $ is the jQuery object in here
// and doesn't conflict with Prototype
});
As described here.
I don't know if you can make Prototype "step down", but this is a perfectly elegant and working solution.
PrototypeJS adds a bit more to the global JavaScript namespace than jQuery does. For example, it adds meanings for: Ajax
, $
, $$
, $F
, Abstract
, Form
, $A
, $H
, $R
, $w
. You can look at a plete list of classes and utilities at api.prototypejs.
So the advice you've gotten is correct, There's no simple equivalent to jQuery.noConflict()
for PrototypeJS.
I can't find any function in http://api.prototypejs/ that will give back the $
, like noConflict()
in jQuery.
I wonder, what feature that you need so you still using prototype? jQuery might have plugins for that feature. Using 2 libraries in same page will make your page bloated by the size of each library.
本文标签: javascriptHow can we resolve conflict between prototype and jQueryStack Overflow
版权声明:本文标题:javascript - How can we resolve conflict between prototype and jQuery? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744672442a2618906.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论