I am implementing pagination where on click i change the style from list view to grid but when i click the next page button or link it is actually redirects me back to again list view button again
$pagination.= "<li><a href='{$url}page={$counter}'>{$counter}</a></li>";
now i want to keep my style same as it was if i have clicked grid so on next page click it remain a grid not turn to list as page load again fetch new record it change my style
$(document).ready(function () {
var elem=$('#container ul');
$('#viewcontrols a').on('click',function(e) {
if ($(this).hasClass('gridview')) {
elem.fadeOut(1000, function () {
$('#container ul').removeClass('list').addClass('grid');
$('#viewcontrols').removeClass('view-controls-list').addClass('view-controls-grid');
//$('#viewcontrols .gridview').addClass('active');
$('#viewcontrols .listview').removeClass('active');
elem.fadeIn(1000);
});
}
else if($(this).hasClass('listview')) {
elem.fadeOut(1000, function () {
$('#container ul').removeClass('grid').addClass('list');
$('#viewcontrols').removeClass('view-controls-grid').addClass('view-controls-list');
$('#viewcontrols .gridview').removeClass('active');
//$('#viewcontrols .listview').addClass('active');
elem.fadeIn(1000);
});
}
});
});
</script>
so is there any why like i declare a such a variable that donot destroy even on page load and manage style or how to do that ?
var elem=$('#container ul');