Make jQuery play nicely with your widgets

Follow

If you use jQuery on your website our widgets might cause things to start acting strangely and/or the jQuery will cause your widgets to start acting strangely (links might not open correctly, but nothing too major). Well, there is a relatively easy fix for this.

Simply find the jQuery code on your site. It'll look something like this:

$(document).ready(function() {

<<Some javascript code will be here. Don't delete it.>>

}

Now, replace that with this (but keep all the code in-between the two {} in place). You'll notice the only real change is replacing the "$" with "jQuery"

jQuery(document).ready(function() { 
}

Now, you also have to go through every line within the curly braces and also look for other statements that start with $, such as:

$(".btn-slide").click(function(){ 
$("#panel").slideToggle("slow"); 
$(this).toggleClass("active"); return false; 
});

So you'll just simply replace all of the "$" with "jQuery"

jQuery(".btn-slide").click(function(){ 
jQuery("#panel").slideToggle("slow"); 
jQuery(this).toggleClass("active"); return false; 
});

And that's it. Now $ is free to be used by the Prototype Library and there won't be any conflicts.

You can also find more information here: http://api.jquery.com/jQuery.noConflict/

Have more questions? Submit a request

Comments

Powered by Zendesk