-
Articles
-
jQuery
-
jQuery running with prototype
jQuery running with prototype
- Posted: 20th August 2010
- Created by: Robert
- Found in: jQuery
jQuery was nice enough to add in a function that helps with conflicting scripts. Typically prototype and jQuery use the $ sign to initialise their scripts. Code to help you achieve no conflicts:
//include your prototype
//include your jquery
//typical jQuery call
$(document).ready(function(){
$("body").css("background", "red");
});
//now that jquery code can be run with conflict like this:
jQuery(document).ready(function(){
jQuery("body").css("background", "red");
});
//but prefixing with that every time not only adds more characters to the code, it just gets annoying
//so use the .noConflict function provided by jquery library
$j = jQuery.noConflict(); //assign a new variable to initialise jquery calls
$j(document).ready(function(){
$j("body").css("background", "red");
});
So after using the function supplied by jQuery, you shouldn't have problems running both at the same time. Good luck.