How To Fix jQuery Conflict

Advertisement

I am not yet become jQuery expert, but I had learned a lot from this code, my jQuery Guru told me about this code very well. So when I got some problem I will go to him :D and almost all my problem will be solved, except this one :D

jQuery-No-Conflict-Hack-and-Tips
jQuery-No-Conflict-Hack-and-Tips

Why he can’t solved this? It’s because last night he can’t be focused on my problem, he still have some jobs at the office, so I am baking you pardon if I was disturbing you my guru ;) So the next answer in my WordPress problem is Uncle Google of course :D .

After look around for a while and analyzing my jQuery code was conflict with other variable code. So I began to explored how to fix it and what should I do, until I got the easy solutions how to fixed the jQuery conflict, all that I need to do just fix the variable, because it need a unique variable to make this jQuery code working.

Baca Juga:   5 Steps for Boosting Creativity

Here’s a jQuery Code Example

My Original jQuery is like this

<script type="text/javascript">
$(document).ready(function() {
$("ul.dropdown-horizontal ul li:has(ul)").addClass("dir");
});

$(function() {
$('#slideshow').cycle({
fx:      'scrollDown',
timeout:  5000,
pause:   1,
speedIn:  2000,
speedOut: 500,
easeIn:  'bounceout',
easeOut: 'backin',
delay:   -2000
});
});
</script>

This code running perfect, if there are no other jQuery code. But it will be got an  error if you has another jQuery code. So to handle this problem, you need to has a unique variable. I mean mostly $ (variables) is the default code of jQuery, so we must to create unique variable

This is an example of the code after I make unique variables,

<script type="text/javascript">
var $jx = jQuery.noConflict();

$jx(document).ready(function() {
$jx("ul.dropdown-horizontal ul li:has(ul)").addClass("dir");
});

$jx(function() {
$jx('#slideshow').cycle({
fx:      'scrollDown',
timeout:  5000,
pause:   1,
speedIn:  2000,
speedOut: 500,
easeIn:  'bounceout',
easeOut: 'backin',
delay:   -2000
});
});
</script>

When you check the second code, you will found a unique variable $jx as a new variable and replace default $.

Baca Juga:   How to Get Into a Linksys Interface

More reference about this problem, you can check on this jQuery Docs. That’s all, I hope you understand with this post  and Have A nice day ;)

  • Pingback: Aris rusak kurniawan()

  • Adi

    Thanks! it’s work fine!!!!!

  • Pingback: Calling Wordpress Actions on Only that particular plugin page to avoid script conflicts()

  • I am having similar problems and have tired everything but it is still not working.

  • Hi Jauhari,

    Thanks,
    You have put me on track with my jquery-conflict, thanks so much for taking the time to write this blog post, 2 years old and it is still helping people out!

    Sandy.

  • Niraj Dubey

    its working fine.

  • Pingback: thyrathany()

  • bisa menyelesaikan konflik antara 2 plugin jquery yang saya pakai
    Thank ytou

  • KMX

    Thanks! it’s work fine.

  • rahul

    i have use jquiry for tooltip but other functions r not working properly what is problem?

  • saya baru saja mengalami hal seperti ini… tadinya saya kira pake JQuery.noConflict() bisa menyelesaikan konflik antara 2 plugin jquery yang saya pakai… ternyata enggak _~_

    dan ternyata ini dipakai untuk mengatasi konflik jquery dengan js library lainnya… _~_ anyway… thx buat infonya pak..

  • Pingback: vivek verma()

  • nuj

    thank you for this very good article. It really helps me fix my problem in wordpress.

  • TR

    Mohon bantuannya dong…
    Sy pake plugin FCG pada theme channel, gambar gak muncul dan error yang muncul di Error Console firefox sbb:
    $$.shared is undefined
    http://…./mootools.v1.11.js
    thanks

  • hello sir,

    I’m new with wordpress and i have been doing some personal projects to improve my experience with it. One of my major resources if i struggle with wordpress is through forums and research and so far everything was going well until now. I added a plugin Featured COntent Gallery from iplexus to add some effects on my website. The current theme that i am using has jquery and slider javascripts. I found out that featured content gallery uses Mootool and has some compatibility issues with jquery hence my Featured content gallery does not work. Found a solution though which is to use a code jquery.noConflict() to solve the problem. But when i insert the code and got the Featured Content Gallery to work, the tab slider now does not work…But when i take out the jquery.noConflict() function in my jquery script, the Featured COntent Gallery does not work and the slider this time works. Can u please take a look at my site to see what is happening? Still a newbie at this but im doing my best to learn.

  • I had the same experience with the conflict. We had the same problem in SharePoint too. So, please read the complete information here.
    http://praveenbattula.blogspot.com/2010/02/jquery-conflict-when-using-different.html

  • Eep

    Hi Jauhari, you put me on track but i solved my problem between two plugins (WPreviewengine and Featured Content Gallery) in WordPress by putting in the following line in jquery.js in wpreviewengine.

    var J = jQuery.noConflict();

    It does the same! but in one comment.

  • Some interesting points, but I’m not sure this really looks at the history of the issue. How has this come about? And where do we go from here? Look forward to you addressing this in future posts.

  • Pingback: jamesgallagher()

  • Pingback: James Gallagher()

  • Where shall I place the code? In the jquery wpmu folder or the theme jquery?

  • Where do I place the code? In the jquery wpmu libraries or the featured content glider jquery? It doesnt refer to drop this code anywhere.

    Thanks for the reply Jauhari!

  • Where do I place the code? In the jquery wpmu libraries or the featured content glider jquery? It doesnt refer to drop this code anywhere.

    Thanks for the reply.

  • Im having a jquery conflict on my feature content glider! The glider jquery is conflicting with photosmash galleries and lightbox-pro in wordpress.mu root page. can you help me?

    • Try my solutions, did it fix your problem?