Home >Web Front-end >JS Tutorial >In-depth understanding of the use of jQuery layui paging control

In-depth understanding of the use of jQuery layui paging control

韦小宝
韦小宝Original
2018-01-13 11:43:311539browse

jquery layuiPaging The control is often used in the project development stage. Let’s introduce the use of jQuery layui paging control through this article. It is very good. Friends who are interested in layui will come together. Let’s take a look

$.getJSON()Introduction to the usage

$.getJSON( url [, data ] [, success(data, textStatus, jqXHR) ] )

url is a required parameter, indicating the address of the json data;

data is an optional parameter, use Send data parameters when requesting data;

success is parameterizable. This is a callback function used to process the requested data.

//内容页面 <br>   
<p id="notice_p"></p><br>   //分页控件
<p id="notice_pages"></p>
<script>
var roolurl = "http://" + window.location.host;
var urlAshx = roolurl + "/aa/Ashx/NoticeInfo.ashx";
//var pages = 0;
//获取分页好的公告内容
function GetNoticeList(curr, cid) {
$.getJSON(urlAshx,
{//参数
action: "notice_action",
courseid: cid,
page: curr || 1,//向服务端传的参数,此处只是演示
nums: 3//每页显示的条数
}, function (datajson) {//成功执行的方法
if (datajson != null) {
var norice_content = "";
//alert(datajson.pages);
$(datajson.rows).each(function (n, Row) {
norice_content += " <p class=&#39;panel panel-default&#39;>";
norice_content += " <p class=&#39;panel-heading&#39;>";
norice_content += " <h3 class=&#39;panel-title&#39;>";
norice_content += Row.CreateDate;
norice_content += " ";
norice_content += Row.Creater;
norice_content += " </h3>";
norice_content += " </p>";
norice_content += " <p class=&#39;panel-body&#39;>";
norice_content += Row.NoticeContent;
norice_content += " </p>";
norice_content += " </p>";
});
$(&#39;#notice_p&#39;).html(norice_content);
//alert(11);
//调用分页
laypage({
cont: &#39;notice_pages&#39;,//容器。值支持id名、原生dom对象,jquery对象。【如该容器为】:<p id="page1"></p>
pages: datajson.pages,//总页数
groups: 5, //连续显示分页数
skip: false, //是否开启跳页
skin: &#39;#AF0000&#39;,
curr: curr || 1, //当前页,
jump: function (obj, first) {//触发分页后的回调
if (!first) {//点击跳页触发函数自身,并传递当前页:obj.curr
GetNoticeList(obj.curr, cid);
}
}
})
}
});
}
$(document).ready(function () {
GetNoticeList(0, &#39;<%=_courseid%>&#39;)
});
</script>


The above is the use of jQuery layui paging control introduced by the editor. I hope it will be helpful to everyone! !

Related recommendations:

Detailed explanation of how layui.js implements form verification function

layui form implementation code sharing

layui tab effect implementation code sharing

The above is the detailed content of In-depth understanding of the use of jQuery layui paging control. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn