For the most part .noConflict() is working fine for me, for example:
$jq('#no-thanks').click( function(event) {
$jq("#olsu").fadeOut();
});
but what is the syntax for this:
$.cookie("example", "foo", { expires: 7 });
I've tried:
$jq.cookie("example", "foo", { expires: 7 })
and
$jq().cookie("example", "foo", { expires: 7 })
any ideas?
This should work:
(function($){
// your all jQuery code inside here
$.cookie("example", "foo", { expires: 7 });
})(jQuery);
Now you can use $
without fear of conflicting with other libraries as long as you put your jQuery code in above self-invoking anonymous function.
More Explanation Here
You have added the jquery.cookie.js
script to your page right?
jQuery.cookie
is not a native jQuery function, so you need to make sure that it's being added, and that it's being correctly added to jQuery if it's happening after noConflict
was called.
As for aliasing jQuery, you can use a self-executing anonymous function to alias jQuery
to $
safely. Additionally the document.ready
shortcut also can be used to alias jQuery
to $
:
(function ($) {
//code goes here
}(jQuery));
jQuery(function ($) {
//document.ready code goes here
});
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