MyBB Community Forums

Full Version: Including jQuery without effecting other scripts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am using a javascript that requires jquery in the header template like?

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="images/clearclouds/scripts/nav.js"></script>

But when I have
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

Included in my header the collapse & expand, and multiquote & delete postbit functions won't work.

How can I include jQuery without effecting any other scripts on MyBB?
I thought you knew how to do it :O

There are several things you could do. The easiest one is to replace the "$" in your jQuery code for something like "jQ" (that's IMO). As the "$" in jQuery means jQuery, but is different for prototype.

At the top of your jQuery code (before the first of your fuctions) add something like jQ = $; And done, just use jQ intead of $
All you need to do is call 'jQuery.noConflict();' and then just put 'jQuery' where you would put the '$'. And as combus said it could also work with 'jQ'. To use that it would be 'jQ.noConflict();'
I tried that noConflict code but than I only get to see the background of the site and the rests disappears...

Hold on...
Grm sorry for being a Dum Dum I forgot to define "jQ" in the "jQuery("div").hide();" part xD.

But this works Toungue
   <script>
     jQuery.noConflict();
     
     // Use jQuery via jQuery(...)
     jQuery(document).ready(function(){
       jQuery("jQ").hide();
     });
     
     // Use Prototype with $(...), etc.
     $('jQ').hide();
   </script>
    // Use Prototype with $(...), etc.
     $('jQ').hide();

^ That makes no sense >.> Just get rid of it. You're saying you want to hide <jQ></jQ> elements on the HTML