How to declare a global window object while using jQuery.noConflict().
I am using following way to avoid Jquery conflict with Mootools
var $j = jQuery.noConflict();
Now I would like to create global shortcut in jquery and tried as
window.cc = function() {// code}
But fails and return er开发者_StackOverflow社区ror as cc not deined.
Instead of creating explicit no conflict object we can use jQuery
in place of $
or your no conflict object name.
Closures?
jQuery.noConflict();
(function($){
//code goes here
// here $ is now jQuery
})(jQuery);
// here $ is not jQuery
and in any of these you can use $
to refer to the jQuery object.
note: I'd also make sure jQuery loads up after any other framework for .noConflict()
to work.
精彩评论