Laraver Ajax Paging

Source: Internet
Author: User

1, set the paging container reference laraver manual My setup code is as follows:

//set up a paging container/app/models/zurbpresenter.php
<?php
classZurbpresenter extends Illuminate\pagination\presenter {
Publicfunction Getpagelinkwrapper ($url, $page, $rel =NULL)
{
$rel = Is_null ($rel)?"':'rel= "'. $rel.'"';
return'<li><a href=javascript:goodslist ("'. $url.'");>'. $page.'</a></li>';
}
Publicfunction Getdisabledtextwrapper ($text)
{
return'<li class= "disabled" ><span>'. $text.'</span></li>';
}
Publicfunction Getactivepagewrapper ($text)
{
return'<li class= "active" ><span>'. $text.'</span></li>';
}
}
//set up a paging template/app/view/page/page.blade.php
<ulclass="pagination">
<?php Echo with (NewZurbpresenter ($paginator))->render ();?>
</ul>
//setting up the configuration file/app/config/view.php
<?php
returnArray
'Paths'= = Array (__dir__.'/.. /views'),
//' pagination ' = ' pagination::slider-3 ',
'pagination'='Page.page',
);
2, the controller calls the method: code as follows

Privatefunction 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;
}
Publicfunction GetList () {
$reult = $ This->brand->paginate (2);
$content = $ This-&GT;TOAJAXTPL ('member::p ublish.ajaxtpl.ajaxsold', $reult);
$data = ['Status'=true,'Data'= $content];
returnResponse::json ($data);
}
3, Ajax page template code

<thead>
<tr>
<th> Products </th>
<th> Amount </th>
<th> Release Time </th>
<th> Expiry Time </th>
<th> Operations </th>
</tr>
</thead>
<tbody>
<?php
foreach($data as$d) {
?>
<tr>
&LT;TD valign="Middle">
<a href="">".. /images/ucenter/nail.jpg"Width=" the"height=" the"/><?php echo $d->title;?></a> </td>
<td>9999 Yuan 11</td>
<td><?php Echo $d->created_at;?></td>
<td><?php Echo $d->validity_date;?></td>
<td><iclass="icon Icon-eye-open tip0"data-toggle="tooltip"Data-placement="Top"title="View"></i> |
<iclass="icon Icon-edit tip0"data-toggle="tooltip"Data-placement="Top"title="Edit"></i> <br/> <iclass="icon Icon-chevron-down tip0"data-toggle="tooltip"Data-placement="Top"title="Lower Shelf"></i> | <iclass="icon Icon-remove tip0"data-toggle="tooltip"Data-placement="Top"title="Delete"></i>
</td>
</tr>
<?php
}
?>
</tbody>
<tfoot>
<tr>
&LT;TD cols='5'> <?php echo $data->links ();?></td>
</tr>
</tfoot>
................
//JS Code:
<script type="Text/javascript">
varTm_classify=[];
function expire () {
varURL ='{{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>

Laraver Ajax Paging

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.