In my project I am using jQuery
in client side and mooTools
in admin side.
I would like to be able to write some part of code (google maps functions, etc) which will be common for both of that libraries.
Is it possible to check if jQuery
or mooTools
libraries are loaded and use proper behaviours ?
$(document).ready(function() {});
or window.addEvent('domready', function(){});
$('#id');
or $('id');
$('googleMapLocalize').addEvent('click', function(){});
or $('googleMapLocalize').bind('click', function(){});
What is the best way ?
You can just type window. jQuery in Console . If it return a function(e,n) ... Then it is confirmed that the jquery is loaded and working successfully. Save this answer.
on if not a function" jQuery error occurs for 2 main reasons: Loading an old version of the jQuery library that doesn't support the on function. Loading a library that overrides the value of the dollar sign $ variable.
Both are adding global varibles with its names:
MooTools and jQuery
So just check:
if(window.MooTools) or if(window.jQuery)
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