Well okay, I am not a master or even an amateur in jQuery albeit I just want to share the fact I just found out while tweaking something in a Wordpress template.

Here it goes. I was making a Plugin for a friend when I got cornered in a jQuery situation. Usually all his pages has 2 instances of jQuery. I got an error of a "$ is not a function" when a second jQuery instance was called with the $ instance already in use.
Example: With the below already in use
If you call another of the $(document) instance. It gives the error I stated earlier.
It was resolved using the below code for the 2nd call.
I was relaxed. Alas, not for too long. What about the 3rd such instance call??
What I faced was the usual scenario to call the instance, the only thing that differed was that a prior 3rd instance was already on call.
Lemme explain
a $(document) was already called, then a jQuery(document) has to be called here-in and following which the usual last $(document) had to be called. What to do?
After a lot of searching, I found nothing. So I resorted toto Hit-And-Trial
Luckily, including a new jQuery file itself just before the 2nd call resolved it.
How? Well, I DO NOT KNOW.
Just give it a shot if you are in a same situation, may be it helps :D
Pictures hosted at our servers and are subject to copyrights of their respective owners.

Here it goes. I was making a Plugin for a friend when I got cornered in a jQuery situation. Usually all his pages has 2 instances of jQuery. I got an error of a "$ is not a function" when a second jQuery instance was called with the $ instance already in use.
Example: With the below already in use
$(document).ready(function() {
$("a").click(function() {
alert("Hello world!");
});
});
If you call another of the $(document) instance. It gives the error I stated earlier.
It was resolved using the below code for the 2nd call.
jQuery.noConflict();
jQuery(document).ready(function() {
jQuery("a").click(function() {
alert("Hello world!");
});
});
I was relaxed. Alas, not for too long. What about the 3rd such instance call??
What I faced was the usual scenario to call the instance, the only thing that differed was that a prior 3rd instance was already on call.
Lemme explain
a $(document) was already called, then a jQuery(document) has to be called here-in and following which the usual last $(document) had to be called. What to do?
After a lot of searching, I found nothing. So I resorted toto Hit-And-Trial
Luckily, including a new jQuery file itself just before the 2nd call resolved it.
<script type="text/javascript" src="js/jquery-latest.js"></script>
<script type="text/javascript">
jQuery.noConflict();
....
....
How? Well, I DO NOT KNOW.
Just give it a shot if you are in a same situation, may be it helps :D
Pictures hosted at our servers and are subject to copyrights of their respective owners.

0 comments
Post a Comment : Please comment responsibly. Harsh remarks and fowl language comments will not be approved.