近期使用了bootstrap的pages控件和ajax来分页获取数据。学习了很多东西,记录下来。
<link href="__PUBLIC__/js/jBootstrapPage-master/jBootsrapPage.css" rel="stylesheet" />
<script src="__PUBLIC__/js/jBootstrapPage-master/jBootstrapPage.js"></script>
<div class="pages">
<span>共{$totalCount}条</span>
<div style="padding-left:100px;">
<p id="pageIndex" style="font-size:20px;font-weight:bold;color:blue;margin-left:150px;"></p>
<ul class="pagination"></ul>
</div>
</div>
createPage(10, 10, 150);
function createPage(pageSize, buttons, total) {
$(".pagination").jBootstrapPage({
pageSize : pageSize,
total : total,
maxPageButton:buttons,
onPageClicked: function(obj, pageIndex) {
var searchNickname = $("#searchNickname") .val();
var searchTitle = $("#searchTitle") .val();
var searchTag = $("#searchTag") .val();
var isHotReplay = $("#isHotReplayHideInput") .val();
$.get("__URL__",{page:pageIndex+1,name:searchNickname,title:searchTitle,isHotReplay:isHotReplay},function(data){
console.log(data);
$(".adv-table").empty().append(data);
});
}
});
}
$page2 = $_REQUEST['page']=="" ? 0 : ($_REQUEST['page'] - 1) * 10;
$this->assign ('searchTag', $_REQUEST['tag']);
$this->assign ('searchTitle', $_REQUEST['title']);
$this->assign ('searchNickname', $_REQUEST['name']);
$this->assign ('searchIsHotReplay', $_REQUEST['isHotReplay']);
$_REQUEST['page'] != ''
? $this->display('list')
: $this->display ();
<table class="display table table-bordered table-striped" id="dynamic-table">
<thead>
<tr>
<th style="width: 10%;">回放标题</th>
<th style="width: 10%;">播主</th>
<th style="width: 10%;">回放封面</th>
<th style="width: 10%;" class="hidden-phone">创建时间</th>
<th style="width: 10%;" class="hidden-phone">观看次数(展示/真实)</th>
<th style="width: 10%;" class="hidden-phone">精选</th>
<th style="width: 10%;" class="hidden-phone">标签</th>
<th style="width: 10%;" class="hidden-phone">排序</th>
</tr>
</thead>
<tbody>
<volist id="vo" name="list">
<tr class="gradeX">
<td>{$vo['title']} <button class="showReplayInfoBtn" onclick="showReplayInfoFunction(this)" myvalue='{$vo[id]}'>详情</button>
</td>
<td>{$vo['nickName']}</td>
<td><a target="_blank" href="{$vo['shareURL']}"><img height='65px'
width='200px'
src="{$vo['streamIMG']}"/></a>
</td>
<td class="center hidden-phone">{$vo['cdate']}</td>
<td class="center hidden-phone">{$vo['lookCount']}/{$vo['lookCount']}</td>
<td class="center hidden-phone">{$vo['isHotReplay']}</td>
<td class="center hidden-phone"><input type="text" value="{$vo['tag']}"
onblur="check132"></td>
<td class="center hidden-phone"><input type="number"
value="{$vo['hotrank']}"
onblur="check133"></td>
</tr>
</volist>
</tbody>
</table>