0

I'm working on a website on wordpress.

I'm using a jquery slider on my home page, using roundabout jquery slider. this jquery plugin works only with jquery 1.2.1. It works fine, because I've added a migrate script on my website.

// Load jQuery
//////////////////////////////////////////////////////////////
add_action('wp_enqueue_scripts', 'my_scripts_method', 200);
function my_scripts_method() {
wp_deregister_script('jquery');
//wp_register_script('jquery', ("http://code.jquery.com/jquery-latest.min.js"), false);
wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"), false);
wp_enqueue_script('jquery');
wp_register_script('migrate', ('http://code.jquery.com/jquery-migrate-1.2.1.js'), false);
wp_enqueue_script('migrate');
}

Now I have a problem because the person in charge of the content added a plugin, and this plugin uses the last jquery version, and when the plugin is activated, I think that the plugin overwrites my migrate script, and I have troubles with my slider.

Is there a way of using 2 different versions of jquery on my website ? Using only jquery 1.2.1 for my slider, and the last jquery version for the rest of my website ? or to avoid the new plugin to overwrite my migrate script ?

thanks a lot for your help !

mmdwc
  • 1,095
  • 6
  • 27
  • 53
  • 1
    http://stackoverflow.com/questions/15383126/jquery-jqueryui-conflict/15383186#15383186 – PSR Oct 08 '14 at 09:47

1 Answers1

0

Absolutely, in fact there's an example of how to do this on jQuery's site:

http://api.jquery.com/jquery.noconflict/

Take a look down the bottom of the page, where two different versions are loaded. You are going to be assigning the jQuery object to a different identifier, and then changing your code to use that new identifier.

You could alternatively do this within an IIFE, as in the example listed on the page (also below):

jQuery.noConflict();
(function( $ ) {
  $(function() {
    // More code using $ as alias to jQuery
  });
})(jQuery);

But I suspect for your purposes it would be easier to load two separate entities and use them separately.

welale
  • 76
  • 1
  • 6
  • thanks @welale for your reply, I read the example, but I don't know how to do it, because when I install the plugin using the latest jquery version, it overwrites my migrate script in my function.php... can you explain me how to do it ? thanks a lot for your help – mmdwc Oct 08 '14 at 10:25