SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Apr 2010
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JQuery and Mootools conflict

    I am working on a site where I have several JQuery scripts which all play nicely together. I need to add a script which uses mootools and now I am having problems due to a conflict. I have read a few articles but am totally lost as I can't seem to get any of the noconflict suggestions to work. It may be due to my lack of understanding.

    At the moment these are the JQuery scripts I am calling...
    Code:
    <script type='text/javascript'>
    jQuery.noConflict();
    jQuery(document).ready(function(){
    jQuery("img.a").hover(
    function() {
    jQuery(this).stop().animate({"opacity": "0"}, "slow");
    },
    function() {
    jQuery(this).stop().animate({"opacity": "1"}, "slow");
    });	
    });
    </script>
    <script type="text/javascript">
    $speed = 600;
    $duration = 8000;
    	$(document).ready(function() {
    $('blockquote').quovolver($speed, $duration);
    	});
    	</script>
    And I want to call use this mootools script...
    Code:
    		<script type="text/javascript">
    		    window.addEvent('domready', function(){
    		        var devmenu = new deviantMenu('deviantMenu-main-conatiner');
    		    });
    		</script>
    The mootools script works on its own, just not when it is added to the rest.

    Any help or pointers would be greatly appreciated. The ideal solution would be a simpler design, but this is what the client wants

  2. #2
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Hi

    When you use jQuery.noConflict(), jQuery no longer uses the $ variable, so when you're trying to call some things like $(document).ready() they will no longer work with jQuery's $ variable.

    I'd like to ask why you have the need to use Mootools and jQuery together. The menu plugin you have there looks like it's pretty easy to replicate with jQuery (or you could have a look at some premade ones).
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  3. #3
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,096
    Mentioned
    448 Post(s)
    Tagged
    8 Thread(s)
    Yes, it would be much more efficient to use one library only. However, I noticed yesterday that Mootools seems to have a verion now that plays nicely with other libraries.

  4. #4
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ralph.m View Post
    However, I noticed yesterday that Mootools seems to have a verion now that plays nicely with other libraries.
    Has it previously not? I was under the impression that if you would for example use jQuery and Mootools together and used jQuery.noConflict(), everything should be dandy as jQuery hands the $ variable back to whatever library originally created it.

    I don't think I've ever actually ran into this issue as I don't tend to mix-and-match libraries
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  5. #5
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,096
    Mentioned
    448 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by AussieJohn View Post
    Has it previously not?
    I'm not sure. But someone asked yesterday about which version of MooTools to donwload, and in comparing the versions I noticed that there was one that is so designed that it won't cause conflicts with other libraries such as jQuery (meaning, I presume, that noConflict wouldn't be needed). But I can't claim to know much about this stuff. Still, if that is the case, it sounds neater than using noConflict.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •