laraver ajax分页
2024-10-19 04:23:22
,设置分页容器参考laraver手册 我的设置代码如下: //设置分页容器 /app/models/ZurbPresenter.php
<?php
class ZurbPresenter extends Illuminate\Pagination\Presenter {
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',
);
,控制器调用的方法:代码如下 private function toAjaxTpl($templateFile='',$data='') {
$viewobj = View::make($templateFile,array('data'=>$data));
$path= $viewobj->getPath();
ob_start();
ob_implicit_flush();
include($path);
$content = ob_get_clean();
return $content;
}
public function getList(){
$reult = $this->brand->paginate();
$content = $this->toAjaxTpl('member::publish.ajaxtpl.ajaxsold',$reult);
$data = ['status'=>true,'data'=>$content];
return Response::json($data);
}
,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="" height=""/><?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='' > <?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>
最新文章
- Kafka副本管理—— 为何去掉replica.lag.max.messages参数
- Delphi_06_Delphi_Object_Pascal_基本语法_04
- 实体生命周期【Entity Lifecycle】(EF基础系列10)
- centos7.0 手动编译 lamp环境
- Ajax的简单请求案例
- 基于Java的Http服务器几种模式演进
- MatLab计算图像圆度
- 使用SQL脚本删除冗余的视图和表
- 【JAVA零基础入门系列】Day11 Java中的类和对象
- python基础的输入字符串的格式化
- 剑指Offer-按之字形顺序打印二叉树
- 设计APP时我们该怎么做
- Dialog样式的Activity
- 有关Spring注解@xxx的零碎知识
- JavaScript夯实基础系列(一):词法作用域
- Oracle入门之对表内容的dml操作
- Jenkins系列之四——设置邮件通知
- 完美解决office2013 错误1402
- Redis学习资料整理
- Global.asax中使用HttpContext为空