Jump to content

help with resolving conflict between two JS libraries


webguync

Recommended Posts

I am having some problems with a page I am working on that utilizes JQuery and MooTools. The JQuery is used on a sliding menu and the Moo Tools is used as a form field checker. i can get one or the other to work, but not both. I did some research at found you can invoke some no conflict code, but what I have tried so far isn't working. My configuration is below.

 

<?php require('../includes/JQuery.php'); ?>//this is where I have all of my JQuery scripts.
<script type="text/javascript">//this initializes the slider for the menu
       jQuery.noConflict();//trying the no conflict
   $(document).ready(function () {
    $('img.menu_class').click(function () {
$('ul.the_menu').slideToggle('medium');
    });
});
    </script>

<script type="text/javascript" src="../js/mootools.js"></script>

 

as the code is now, the MooTools feature works, but the JQuery does not. I also tried moving the MootTools call above the JQuery call and that enables the JQuery slide to work, but then the MooTools effect doesn't work.

Link to comment
Share on other sites

still a little confused on this. Taking the following code, what would I need to do so that it won't conflict with other JQuery code or other JS libraries.

 

$(document).ready(function () {
    $('img.menu_class').click(function () {
$('ul.the_menu').slideToggle('medium');
    });
});

Link to comment
Share on other sites

well as I interpret this is what I need to do.

 

var $jq = JQuery.noConflict();
$jq(document).ready(function () {
    $jq('img.menu_class').click(function () {
$jq('ul.the_menu').slideToggle('medium');
    });
});

 

but on a page I have a JQuery slider menu (the code above), the menu doesn't work on the same page as a form which also uses the mootools.js library to submit data.

 

one or the other works but not both.

 

Link to comment
Share on other sites

  • 6 months later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.