I have defined a JQfactory plugin like this
(function($, window, document) {
$.jqfactory('my.tooltip', {
/* My tooltip code */
}, false);
}(jQuery, window, document));
Now assuming I have included Bootstrap framework also in my page, and I want to call my version of tooltip()
only, not the bootstrap version. How do I achieve using the namespace $.my.tooltip
?
As mentioned on the Bootstrap website:
http://getbootstrap.com/javascript/#js-noconflict
// return $.fn.tooltip to previously assigned value
var bootstrapTooltip = $.fn.tooltip.noConflict();
// give $().bootstrapBtn the Bootstrap functionality
$.fn.bootstrapTooltip = bootstrapTooltip;
You would use $.bootstrapTooltip
to call the Bootstrap tooltip (if you ever want to use it). You'll be able to use $.tooltip
for something else.
jQuery noConflict doesn't solve this issue, because it only separates the different jQuery versions. The tooltip
function isn't part of the original jQuery code, so it doesn't make sense to use jQuery noConflict, unless you want to load 2 different jQuery versions and use 2 different jQuery objects "$" and "$$" for instance. This would definitely cause many problems later on because the developer will have a spaghetti code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With