[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 322
  • Last Modified:

Jquery Conflict

I'm working on a website that uses 2 jquery plugins. The menu and the background slider.
When I use both at the same time only the menu works as intended.
If I remove the menu scripts the backslider works normally.

Link: www.avnation.co/index.php
0
zahimezher
Asked:
zahimezher
  • 3
  • 2
  • 2
  • +1
2 Solutions
 
duncanb7Commented:
Did you read this article before ?

http://blog.nemikor.com/2009/10/03/using-multiple-versions-of-jquery/

it might be similar to your issue

Hope understand your question completely, if not , please point it out


Duncan
0
 
GaryCommented:
You have a conflict between MooTools and jQuery - both are trying to use $ - so to use the jQuery library you just use jQuery instead of $

Change
$('#bs0').backslider({

to
jQuery('#bs0').backslider({
0
 
InsoftserviceCommented:
$(document).ready(function(){$("div").hide(); // picked up by jQuery and MooTools});

Solution

jQuery(document).ready(function($){$("div").hide(); // picked up by jQuery only});

Or
jQuery(document).ready(function(){jQuery("div").hide(); // picked up by jQuery only});

Or try this one

var $j = jQuery.noConflict(); // Use jQuery via $j(...)

$j(document).ready(function(){

$j("div").hide();

});



jQuery.noConflict()(function(){ // code using jQuery

});

(function($) { /* some code that uses $ */ })(jQuery)


Another way to resolve

http://www.simplifyyourweb.com/index.php/developers-corner/90-solving-jquery-jquery-and-jquery-mootools-conflict-issues-with-the-jquery-easy-plugin


// Disable the $ global alias completely
jQuery.noConflict();

// For jQuery scripts
(function($){

// set a local $ variable only available in this block as an alias to jQuery
... here is your jQuery specific code ...

})(jQuery);

// For Mootols scripts
(function($){

// set a local $ variable only available in this block as an alias
// to Mootools document.id
... here is your Mootools specific code ...

})(document.id);
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
InsoftserviceCommented:
Agreed with your points for removing the links, but little confuse about other statement that i had repeated other experts suggestion as there are only few methods to resolve this issue which i had written so it might have others comments too.
So do author is viewable my comments or should i repost the same comment removing the links
0
 
GaryCommented:
You repeated what I had already said but your whole comment is just a copy/paste from two other websites - that's called plagiarism.
And now again you have just copy/pasted another persons work passing it off as your own.
All the while not providing a real answer to the problem
0
 
zahimezherAuthor Commented:
Hello,

@duncanb7 Thank you but this is more of a do it your self kinda help and not a solution.

@GaryC123 Your first comment was simple and did the trick, everything is working now.

@insoftservice thats exactly what @GaryC123 posted before you did and its basically the same solution but with more details...

@mlmcc Should I reward @GaryC123 all the point or divide them equally between GaryC123 and @insoftservice

It's always mega confusing when it comes to rewarding point and similar solutions are posted.
This happened before and I end up with a re-opened question to redistribute points.

Awaiting your advice.
0
 
zahimezherAuthor Commented:
Mark your comment was very helpful. Thank you for the time you put into explaining all this in detail.

I honestly though @GaryC123 nailed it in the simplest way due to going through the source code.

I would like to award  points to @insoftservice for the time and effort put in to this as well. But fair is fair and Gary posted the simplest / most effective solution first.

Thank you all for your help and time.

Regards
0
 
zahimezherAuthor Commented:
@mlmcc any action required from my side?

Thank you
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now