Reputation: 15550
I have developed a wordpress plugin that uses jquery.
This plugin have some javascript functions/operations in custom js file.
As jquery functions, i have used $
sign for selector.
Everything is ok up to now. However, some users use wordpress plugins that uses jquery and that plugin overrided $
sign as jQuery
or $j
.
If i deregister my jquery.js, my plugin doesnt work, if i deregister other jquery.js other plugin doesnt work. For example, i am using twitter-bootsrap-modal.js in my plugin and it uses $
sign.
When i install another plugin on my wordpress that uses $j
system doesn't work.
Have you any strategies for that kind of situations?
Upvotes: 0
Views: 253
Reputation: 6500
Before using $j
you should declare it using .noConflict()
.
You can also use it for your plugin, Wordpress require it most of the time because it use different libraries.
So at the to of your plugin write:
var $j = jQuery.noConflict(); //$j could be also j, or $r, everything you want, is a variable.
Then replace all your $
with your new variable used in the no conflict.
Hope it help.
Upvotes: 2