jQuery和Mootools,.noConflict失败 [英] Jquery And Mootools, .noConflict is failing

查看:75
本文介绍了jQuery和Mootools,.noConflict失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要使用mootools日历的应用程序,但是,我将jquery用于我的主要应用程序结构.

I have an application that requires the use of a mootools calendar, however, I use jquery for my main app structure.

我在使用jquery的mootools时,都无法正常工作,而当我只有一个时,它们就可以正常工作.我进行了一些研究,说我可以使用一种名为.noconflict的方法,尽管尝试了一下,但仍未解决问题.也许有人可以更好地向我解释在哪里进行实际的.noconflict呼叫,也许可以帮助我完成此工作.

As soon as I have mootools in with jquery, neither work, and when I have only one, they work fine. I did some research saying I could use a method called .noconflict, and while i've tried, I have not gotten it to solve my issue. Perhaps someone could better explain to me where to do the actual .noconflict calls, and perhaps help me get this working.

谢谢!

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        var fixHeight = function () {
                var gutter = 50;
                var newHeight = $(window).height() - (gutter*2);
                $('#container').height(newHeight);
        }
        $(function(){ 

            fixHeight();
            $('ul#nav li.item').each(function(index) {
                if ($(this).attr("name") == "media") {
                    $(this).attr("id","active");
                }
            });
            $('input').focus(function() {
                $(this).attr("value","");
            }).blur(function() {
                $(this).attr("value",$(this).attr("original-value"));
            });

            $(window).resize(function() {
                fixHeight();
            }).load(function() {
                fixHeight();
            });

        });  
     </script>
     <script type="text/javascript" src="http://taptouchclick.com/js/mootools-1.2.4-core-yc.js"></script>
     <script type="text/javascript">
        window.addEvent('domready', function(){
             var smoothCalendar = new SmoothCalendar("calendar");
        });
    </script>

推荐答案

如果您简单地致电:

jQuery.noConflict();

...包括Mootools JS文件之前.

...before including the Mootools JS file.

然后可以通过使用jQuery而不是$来使用jQuery函数.示例:

You can then use jQuery functions by using jQuery instead of $. Example:

jQuery('.selector').hide();  // instead of $('.selector').hide();

这篇关于jQuery和Mootools,.noConflict失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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