I am trying to implement a cookie to apply to all pages of my locally developed site (http://localhost888/develop
). For some reason, I cannot get it to work by adding 'path /'. Below is the code I am currently using:
Here is the full code being used:
$(document).ready(function(){
var wrap = $('#viewMode'),
viewMode = $.cookie( 'view-mode' );
wrap.children().hide();
$('.js-view-mode').on( 'click', 'a',function( e ){
e.preventDefault();
var t = $(this),
type = t.attr('href');
if( t.parent().hasClass('s') ) return;
t.parent().addClass('s')
.siblings().removeClass('s');
var lheight = $("#viewMode").height();
if(lheight != 0){
$("#viewMode").css("height",lheight+"px");
}
wrap.children().fadeOut(); $(type).delay(500).fadeIn(function(){
$("#viewMode").css("height","auto");
});
viewMode = $.cookie( 'view-mode', type );
});
if ( viewMode ) {
$('.js-view-mode a[href='+ viewMode +']').trigger('click');
} else {
$('.js-view-mode li:first a').trigger( 'click' );
}
});
I have attempted to add the following to line 3 without success:
viewMode = $.cookie( 'view-mode', {path: '/'} );