Jquery-Mootools冲突 [英] Jquery-Mootools conflict

查看:70
本文介绍了Jquery-Mootools冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试制作2个脚本(1个mootol和1个jquery)在同一页面上工作无济于事。正在研究许多论坛和所有但我仍然无法让2个同时工作。

i have been trying to make 2 scripts(1 mootol and 1 jquery) work at the same page to no avail..been researching many a forums and all but i still cant make the 2 work simultaneously.

这是我在标题中的样子:

this is how it looks in my header:

<script type="text/javascript" src="<?php bloginfo('url'); ?>/wp-content/plugins/buddypress/bp-themes/bp-default/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript"> 
     jQuery.noConflict();
$(document).ready(function () { 
         var hide = false; 
     $("#posts-menu, .submenu").hover(function(){ 
         if (hide) clearTimeout(hide); 
         $(".submenu").fadeIn(); 
     }, function() { 
         hide = setTimeout(function() { 
             $(".submenu").fadeOut("slow"); 
         }, 250); 
     }); 

})(jQuery);
    </script>       
<script type="text/javascript" src="<?php bloginfo('url'); ?>/wp-content/plugins/buddypress/bp-themes/bp-default/js/mootools-core-1.3.2.js"></script>
<script type="text/javascript" src="<?php bloginfo('url'); ?>/wp-content/plugins/buddypress/bp-themes/bp-default/js/mootools-more-1.3.1.1.js"></script>
<script type="text/javascript" src="<?php bloginfo('url'); ?>/wp-content/plugins/buddypress/bp-themes/bp-default/js/wall.js"></script>
<script type="text/javascript" src="<?php bloginfo('url'); ?>/wp-content/plugins/buddypress/bp-themes/bp-default/js/wall-lide.js"></script>

<script type="text/javascript">
<!-- 

window.addEvent('domready',function(){


    // -- horizontal
    var myHorizontalSlide = new Fx.Slide('login-welcome-div-slide', {mode: 'vertical'});


    $('slideout').addEvent('click', function(event){
        event.stop();
        myHorizontalSlide.slideOut();
    });


});

// -->  
</script>

我管理了mootools脚本,即使你有一个jquery.js来调用...
你可以看到我已经在第3行使用了 jQuery.noConflict(); ..

i managed the mootools script to work even if theres a jquery.js call... you can see that i already used jQuery.noConflict(); in the 3rd line..

问题如果jquery.noconflict存在,但是jquery脚本不起作用,mootool脚本是有效的!现在如果删除jquery.noconflict它现在反过来,jquery脚本工作,但不是mootool脚本..我只是不能使其中的2个工作!

the problem is that the mootool scripts works if the jquery.noconflict is there but the jquery scripts doesnt work! now if remove the jquery.noconflict its now the other way around, the jquery script works but not the mootool scripts..i just couldnt make the 2 of them work!

任何类型的帮助将不胜感激..

any kind of help would be greatly appreciated..

推荐答案

问题是你没有在匿名函数中包含jQuery代码。试试这个:

The problem is that you are not enclosing the jQuery code within an anonymous function. Try this:

(function($){
    // inside here $ will always mean jQuery
    $(document).ready(function () { 
         var hide = false; 
         $("#posts-menu, .submenu").hover(function(){ 
             if (hide) clearTimeout(hide); 
             $(".submenu").fadeIn(); 
         }, function() { 
             hide = setTimeout(function() { 
                 $(".submenu").fadeOut("slow"); 
             }, 250); 
         }); 
    });
})(jQuery);

这篇关于Jquery-Mootools冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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