Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript My experience using Jquery and mootools together

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #35457
    SycoLV
    Member

    Hey Guys! Recently I had a client that wanted a Fancybox for his webpage, but hes webpage was using Mootools. Ofcorse, I bet there is many plugins like Fancybox for mootols, but I wanted to see wat happens if i use both.

    But when I inserted the jquery and Fancybox script the dropdown menu witch was using mootools or the fancybox didnt work, depended in with order I inserted the javascripts. So I made a little research and found a jQuery.noConflict();

    The original js defenition looked like that:


    $(document).ready(function() {
    $("a#example1").fancybox();
    });

    The thing is that Jquery and Mootools uses $ as a function or variable name.

    So I used the jQuery.noConflict(); like this :


    var noConflict = jQuery.noConflict();
    noConflict(document).ready(function() {
    noConflict("a#example1").fancybox();
    });

    And now it works perfect for me. Maybe You Guys know a better way to deal with this problem, but this was my idea how to solve this problem. I hope my little experience with this will be useful for someone.

    #92019
    rolf
    Member

    Maybe instead of using noConflict as the var name you could use $j which is a bit shorter ;)

    Basic explanation for those who want to read more: http://docs.jquery.com/Using_jQuery_with_Other_Libraries

    I would stress to the client to use just 1 library, or better, the devs should really tell the client that using two libraries is silly (a lot of extra kb’s to download for no reason).

    There are some good resources online on how to use both together, but only if you really must I’d say it’s worth checking out. Like http://moo4q.com

    #92028
    jamygolden
    Member

    I usually do something like this – which hasn’t given me problems before:

    jQuery.noConflict();
    jQuery(document).ready(function($) {
    $("a#example1").fancybox();
    });
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.