I am trying to save and use a cookie to know what kind of viewStyle user wants. There is a swich for this cookie.
This is how I want to update the cookie
$('body').on('click','.viewBy li a',function(){
if($('.titular').length > 0){
$.cookie('viewBy','titular',{expires:30});
}else{
$.cookie('viewBy','',{expires:30});
}
});
And this is how i am checking
if($.cookie('viewBy')){
$('.viewBy li').toggleClass('active');
$('.recetaTitular').addClass('titular');
}
But i get this firebug error:
$.cookie is not a function
[Parar en este error]
I tried with
if(typeof $.cookie('viewBy') != 'undefined' &&($.cookie('viewBy'))){
$('.viewBy li').toggleClass('active');
$('.recetaTitular').addClass('titular');
}
But getting same error
$.cookieis not a jQuery function. You need to include a plugin, perhaps this one:https://github.com/carhartl/jquery-cookie
After you load the jQuery plugin.