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

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.
Here’s a jQuery Code Example
My Original jQuery is like this
[sourcecode language=”javascript”]<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>[/sourcecode]
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,
[sourcecode language=”javascript”]<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>[/sourcecode]
When you check the second code, you will found a unique variable $jx as a new variable and replace default $.
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 ;)
Tinggalkan Balasan