简体   繁体   中英

Issue with $.noConflict, jquery.cookie, and bootstrap

I am trying to use jquery.cookie to handle all of my cookie needs. Whenever I try to create a cookie, I get the following error:

Uncaught TypeError: Object function (e,t){return new x.fn.init(e,t,r)} has no method 'cookie'

I read to use $.noConflict() to fix this issue, which did indeed resolve the error above. However, when I use it, I get errors thrown about bootstrap's .tooltip() , as well as $.sidr which I use for my slide out menu.

Does someone have some suggestions on resolving this?

Thanks

Once you invoke noconflict mode you can no longer reference jQuery with $

I usually do it like this:

$j = jQuery
$j.noConflict();


$j(function(){

    $j('yourSelector').tooltip();

});

There is probably a more efficient way than duplicating the jQuery function, suggestions are always welcome

I initially loaded jquery.cookie in the <head> of my site. Moving it to the very bottom fixed it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM