[jQuery] cookie check within ajah loaded page doesnt work
Hi all,
I have some code that checks for a cookie named sumview. if the value
is 'hide' I dont want to display a div with id viewsummary. Problem is
that the summary div is in the page that loads from an ajax request
using the form plugin. The ajax loaded page ignores the cookie. Do I
need to check the cookie within the page being loaded from the ajax
request? Better way to do this.
// summary close
$(document).ready(function(){
var c = 'sumview';
$("#viewsummary").hide();
// summary display check
if ($.cookie(c) == 'hide') {
$("#sumswitch_on").show(); // show turn on sumary link
$("#sumswitch_off").hide(); // hide turn off smmary link
$("#viewsummary").hide(); // summary div to hide
} else {
$("#sumswitch_on").hide();
$("#sumswitch_off").show();
$("#viewsummary").show();
};
// slides down, up, the divs for summary
$('#view_sum_on').click(function() {
$("#viewsummary").slideDown('slow');
$("#sumswitch_on").hide();
$("#sumswitch_off").show();
$.cookie(c, '', {expires: -1});
return false;
});
$('#view_sum_off').click(function() {
$("#viewsummary").slideUp('slow');
$("#sumswitch_on").show();
$("#sumswitch_off").hide();
$.cookie(c, 'hide', {expires: 1});
return false;
});
});