scriptaculous和JQuery不合作 [英] scriptaculous and JQuery do not collaborate

查看:104
本文介绍了scriptaculous和JQuery不合作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery滑块浏览同一页面上的图像和Scriptaculous滑块动画.如果我将它们放在两个单独的页面中,它们会完美地工作.

I am using jQuery slider to browse images and Scriptaculous slider animation on the same page. They work perfectly if I put in two separate pages.

当我以这种方式订购代码时.

When I order the code in this way.

<script type="text/javascript" src="/scripts/prototype.js"></script>     
<script type="text/javascript" src="/scripts/scriptaculous.js?load=effects"></script>               
<script type="text/javascript" src="/scripts/lightbox.js"></script> 

<script type="text/javascript" src="/scripts/coda-slider-2.0/jquery-1.3.2.min.js"></script> 
<script type="text/javascript" src="/scripts/coda-slider-2.0/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="/scripts/coda-slider-2.0/jquery.coda-slider-2.0.js"></script>

<script type="text/javascript">
    jQuery(document).ready(function(){      
        jQuery('#coda-slider-1').codaSlider({
        dynamicArrows: false,
        dynamicTabs: false
    });
    });            
</script>

脚本幻灯片正在运行,而jQuery幻灯片停止运行. 当我这样订购时.

Scriptaculous slide is working and jQuery slide stops working. When I order this way.

<script type="text/javascript" src="/scripts/coda-slider-2.0/jquery-1.3.2.min.js"></script> 
<script type="text/javascript" src="/scripts/coda-slider-2.0/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="/scripts/coda-slider-2.0/jquery.coda-slider-2.0.js"></script>

<script type="text/javascript">
    jQuery(document).ready(function(){      
        jQuery('#coda-slider-1').codaSlider({
        dynamicArrows: false,
        dynamicTabs: false
    });
    });            
</script>

<script type="text/javascript" src="/scripts/prototype.js"></script>     
<script type="text/javascript" src="/scripts/scriptaculous.js?load=effects"></script>               
<script type="text/javascript" src="/scripts/lightbox.js"></script> 

jQuery开始工作,而Scriptaculous幻灯片停止工作. 然后我寻找了一些解决方案,并指出使用jQuery.noConflict();.并用jQuery替换选择器$可以解决问题,但事实并非如此.我将这两件事放在代码中,然后尝试这种方式.

jQuery starts working and Scriptaculous slide stops working. Then I looked for some solution around and it is stated that using jQuery.noConflict(); and replacing selector $ with jQuery can solve the problem but it doesn't. I put these two things in the code and try this way.

script type="text/javascript" src="/scripts/prototype.js"></script>     
<script type="text/javascript" src="/scripts/scriptaculous.js?load=effects"></script>               
<script type="text/javascript" src="/scripts/lightbox.js"></script> 

<script type="text/javascript" src="/scripts/coda-slider-2.0/jquery-1.3.2.min.js"></script> 
<script type="text/javascript" src="/scripts/coda-slider-2.0/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="/scripts/coda-slider-2.0/jquery.coda-slider-2.0.js"></script>

<script type="text/javascript">
    jQuery.noConflict();
    jQuery(document).ready(function(){      
        jQuery('#coda-slider-1').codaSlider({
        dynamicArrows: false,
        dynamicTabs: false
    });
    });            
</script>

这只会强制jQuery不管其顺序如何工作,并且会导致Scriptaculous停止工作.

That only forces jQuery to work no matter what order it and it makes Scriptaculous stop working.

这里有任何建议.干杯.

Any suggestion is appreciated here. Cheers.

推荐答案

我对Scriptaculous不太了解,但马上有两件事:

I'm not so well versed with Scriptaculous, but just two things right off the bat:

  1. 如果您打算将jQuery与另一个库一起使用(然后调用.noConflict()),请先加载jQuery ,然后再调用.noConflict(),然后 加载其他库.在这种情况下,原型和脚本化.如果我没记错的话,这样更安全.

  1. If you're planning to use jQuery with another library (then call .noConflict()), load jQuery first, then call .noConflict(), then load the other libraries. In this case, prototype and scriptaculous. Safer that way, if I'm not mistaken.

确保jQuery coda滑块插件实际支持.noConflict().我认为这就是上面的Derek想要说的---一旦您调用.noConflict(),jQuery就会将$变量释放回公开状态(例如,以脚本方式使用).如果尾随滑块大量使用$变量(而不适应.noConflict()),那可能是个大问题.

Make sure that the jQuery coda slider plugin actually supports .noConflict(). I think this is what Derek above was trying to say --- once you've called .noConflict(), jQuery releases the $ variable back into the open (for scriptaculous to use, for example). If the coda slider uses the $ variable heavily (without adapting to .noConflict()), that could be a big problem.

这篇关于scriptaculous和JQuery不合作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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