• laraver ajax分页


    1,设置分页容器参考laraver手册 我的设置代码如下:

    //设置分页容器  /app/models/ZurbPresenter.php
    <?php 
        class ZurbPresenter extends IlluminatePaginationPresenter {
        public function getPageLinkWrapper($url, $page, $rel = null)
        {
            $rel = is_null($rel) ? '' : ' rel="'.$rel.'"';
            return '<li><a href=javascript:goodslist("'.$url.'");>'.$page.'</a></li>';
        }
        public function getDisabledTextWrapper($text)
        {
            return '<li class="disabled"><span>'.$text.'</span></li>';
        }
        public function getActivePageWrapper($text)
        {
            return '<li class="active"><span>'.$text.'</span></li>';
        }
    }
    //设置分页模板 /app/view/page/page.blade.php
    <ul class="pagination">
        <?php echo with(new ZurbPresenter($paginator))->render(); ?>
    </ul>
    //设置配置文件 /app/config/view.php
    <?php
    return array(
        'paths' => array(__DIR__.'/../views'),
        //'pagination' => 'pagination::slider-3',
        'pagination' => 'page.page',
    );
    2,控制器调用的方法:代码如下

    private function toAjaxTpl($templateFile='',$data='') {
            $viewobj = View::make($templateFile,array('data'=>$data));
            $path= $viewobj->getPath();
            ob_start();
            ob_implicit_flush(0);
            include($path);
            $content = ob_get_clean();
            return $content;
        }
    public function getList(){
            $reult = $this->brand->paginate(2);
            $content = $this->toAjaxTpl('member::publish.ajaxtpl.ajaxsold',$reult);
            $data = ['status'=>true,'data'=>$content];
            return Response::json($data);
        }
    3,ajax分页模板代码

    <thead>
        <tr>
            <th>商品</th>
            <th>金额</th>
            <th>发布时间</th>
            <th>过期时间</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
    <?php 
        foreach($data as $d){
    ?>
        <tr>
          <td valign="middle">
                    <a href=""><img src="../images/uCenter/nail.jpg" width="80" height="80"/><?php echo $d->title ; ?></a>            </td>
          <td>9999元11</td>
          <td><?php echo $d->created_at; ?></td>
          <td><?php echo $d->validity_date; ?></td>
           <td><i class="icon icon-eye-open tip0"  data-toggle="tooltip" data-placement="top" title="查看"></i> | 
                       <i class="icon  icon-edit tip0" data-toggle="tooltip" data-placement="top" title="编辑"></i>           <br />                    <i class="icon  icon-chevron-down tip0" data-toggle="tooltip" data-placement="top" title="下架"></i> |                     <i class="icon icon-remove tip0"  data-toggle="tooltip" data-placement="top" title="删除"></i>
          </td>
        </tr>
    <?php
        }
    ?>
    </tbody>
    <tfoot>
        <tr>
        <td cols='5' > <?php echo $data->links(); ?></td>
        </tr>
    </tfoot>
    ................
    //js代码:
    <script type="text/javascript">
        var tm_classify=[];
        function expire(){
            var url = '{{ route("member.publish.getlist") }}';
             $.getJSON(url,function(data){
            console.info(data);
            $('#expire').html(data.data);
            }); 
        };
        function goodslist(url){
        $.getJSON(url,function(data){
            $('#expire').html(data.data);
        });
        }
    </script>
  • 相关阅读:
    yellow joke 3
    JavaScript下拉菜单(1)
    Java程序员面试三十二问
    Oracle里时间的应用
    ·Java读取properties文件
    Web 窗体用户控件
    怎么解决层被flash挡住的问题?
    自定义控件
    关于mysql中的DDL,DML,DQL和DCL
    自定义一个简单连接池以及常见连接池的使用
  • 原文地址:https://www.cnblogs.com/qhorse/p/4701104.html
Copyright © 2020-2023  润新知