doudu2591 2017-02-02 15:34
浏览 64
已采纳

如何在服务器端调用分页停止页面重新加载?php

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');   
  • 写回答

2条回答 默认 最新

  • doumengxue7371 2017-02-02 15:41
    关注

    You could save the selected style in the localStorage. On page load you can load the style from the localStorage again.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 视频编码 十六进制问题
  • ¥15 Xsheii7我安装这个文件的时候跳出来另一个文件已锁定文件的无一部分进程无法访问。这个该怎么解决
  • ¥15 unity terrain打包后地形错位,跟建筑不在同一个位置,怎么办
  • ¥15 FileNotFoundError 解决方案
  • ¥15 uniapp实现如下图的图表功能
  • ¥15 u-subsection如何修改相邻两个节点样式
  • ¥30 vs2010开发 WFP(windows filtering platform)
  • ¥15 服务端控制goose报文控制块的发布问题
  • ¥15 学习指导与未来导向啊
  • ¥15 求多普勒频移瞬时表达式