Skip to content

Commit b2b5c99

Browse files
author
杜美瑶
committed
修复资源中心点击下一页初始化页数错误问题 --reviewed by huangqh
1 parent 15bdbb0 commit b2b5c99

File tree

2 files changed

+68
-62
lines changed

2 files changed

+68
-62
lines changed

examples/leaflet/iPortalQueryResources.html

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ <h5 class='panel-title text-center' data-i18n="resources.title_iPortalQueryResou
200200
$(document).ready(function () {
201201
//加载完DOM后,开始资源数据查询并添加
202202
queryResouces(queryParams);
203+
initClickEvent();
203204
});
204205

205206
// 查询iPortal中的资源
@@ -252,41 +253,43 @@ <h5 class='panel-title text-center' data-i18n="resources.title_iPortalQueryResou
252253
$(".glyphicon-chevron-right").parent().removeClass('disable');
253254
$(".glyphicon-chevron-left").parent().removeClass('disable');
254255
$("#resourcesListPaging > .pagination > .pagDom").remove();
255-
for (var i = 0; i < totalPages; i++) {
256-
if (i == (resourceCurrentPage - 1)) {
257-
var resourcesListPaging = $("<li class='pagDom' >" + "<a href='JavaScript:void(0)' class='resourcesListChang active' >" + (i + 1) + "</a>" + "</li>")
258-
} else {
259-
var resourcesListPaging = $("<li class='pagDom'>" + "<a href='JavaScript:void(0)' class='resourcesListChang ' >" + (i + 1) + "</a>" + "</li>")
260-
}
261-
resourcesListPaging.insertBefore($("#resourcesListPaging > .pagination > li:last-child"));
256+
for (var i = 0; i < totalPages; i++) {
257+
if (i == (resourceCurrentPage - 1)) {
258+
var resourcesListPaging = $("<li class='pagDom' >" + "<a href='JavaScript:void(0)' class='resourcesListChang active' >" + (i + 1) + "</a>" + "</li>")
259+
} else {
260+
var resourcesListPaging = $("<li class='pagDom'>" + "<a href='JavaScript:void(0)' class='resourcesListChang ' >" + (i + 1) + "</a>" + "</li>")
262261
}
263-
//根据初始页面的设置,判断向前/后 翻页按钮是否需要禁止点击
264-
if (resourceCurrentPage == 1) {
265-
$(".glyphicon-chevron-left").parent().addClass('disable');
266-
// 只有一页
267-
if(resourceCurrentPage == totalPages){
268-
$(".glyphicon-chevron-right").parent().addClass('disable');
269-
}
270-
} else if (resourceCurrentPage == totalPages) {
262+
resourcesListPaging.insertBefore($("#resourcesListPaging > .pagination > li:last-child"));
263+
}
264+
//根据初始页面的设置,判断向前/后 翻页按钮是否需要禁止点击
265+
if (resourceCurrentPage == 1) {
266+
$(".glyphicon-chevron-left").parent().addClass('disable');
267+
// 只有一页
268+
if(resourceCurrentPage == totalPages){
271269
$(".glyphicon-chevron-right").parent().addClass('disable');
272270
}
273-
//为分页列表项绑定事件
274-
$('#resourcesListPaging>.pagination').delegate('.resourcesListChang', 'click', function (e) {
275-
if (resourceCurrentPage != parseInt(e.currentTarget.text)) {
276-
resourceCurrentPage = parseInt(e.currentTarget.text)
277-
paginationClick(resourceCurrentPage);
278-
}
279-
});
280-
//切换到上一页
281-
$(".glyphicon-chevron-left").parent().click(function () {
282-
resourceCurrentPage--;
283-
paginationClick(resourceCurrentPage);
284-
});
285-
//切换到下一页
286-
$(".glyphicon-chevron-right").parent().click(function () {
287-
resourceCurrentPage++;
271+
} else if (resourceCurrentPage == totalPages) {
272+
$(".glyphicon-chevron-right").parent().addClass('disable');
273+
}
274+
};
275+
function initClickEvent() {
276+
//为分页列表项绑定事件
277+
$('#resourcesListPaging>.pagination').delegate('.resourcesListChang', 'click', function (e) {
278+
if (resourceCurrentPage != parseInt(e.currentTarget.text)) {
279+
resourceCurrentPage = parseInt(e.currentTarget.text)
288280
paginationClick(resourceCurrentPage);
289-
});
281+
}
282+
});
283+
//切换到上一页
284+
$(".glyphicon-chevron-left").parent().click(function () {
285+
resourceCurrentPage--;
286+
paginationClick(resourceCurrentPage);
287+
});
288+
//切换到下一页
289+
$(".glyphicon-chevron-right").parent().click(function () {
290+
resourceCurrentPage++;
291+
paginationClick(resourceCurrentPage);
292+
});
290293
};
291294
//页面的点击事件,触发的function
292295
function paginationClick(resourceCurrentPage) {

examples/openlayers/iPortalQueryResources.html

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ <h5 class='panel-title text-center' data-i18n="resources.title_iPortalQueryResou
200200
$(document).ready(function () {
201201
//加载完DOM后,开始资源数据查询并添加
202202
queryResouces(queryParams);
203+
initClickEvent();
203204
});
204205

205206
// 查询iPortal中的资源
@@ -252,41 +253,43 @@ <h5 class='panel-title text-center' data-i18n="resources.title_iPortalQueryResou
252253
$(".glyphicon-chevron-right").parent().removeClass('disable');
253254
$(".glyphicon-chevron-left").parent().removeClass('disable');
254255
$("#resourcesListPaging > .pagination > .pagDom").remove();
255-
for (var i = 0; i < totalPages; i++) {
256-
if (i == (resourceCurrentPage - 1)) {
257-
var resourcesListPaging = $("<li class='pagDom' >" + "<a href='JavaScript:void(0)' class='resourcesListChang active' >" + (i + 1) + "</a>" + "</li>")
258-
} else {
259-
var resourcesListPaging = $("<li class='pagDom'>" + "<a href='JavaScript:void(0)' class='resourcesListChang ' >" + (i + 1) + "</a>" + "</li>")
260-
}
261-
resourcesListPaging.insertBefore($("#resourcesListPaging > .pagination > li:last-child"));
256+
for (var i = 0; i < totalPages; i++) {
257+
if (i == (resourceCurrentPage - 1)) {
258+
var resourcesListPaging = $("<li class='pagDom' >" + "<a href='JavaScript:void(0)' class='resourcesListChang active' >" + (i + 1) + "</a>" + "</li>")
259+
} else {
260+
var resourcesListPaging = $("<li class='pagDom'>" + "<a href='JavaScript:void(0)' class='resourcesListChang ' >" + (i + 1) + "</a>" + "</li>")
262261
}
263-
//根据初始页面的设置,判断向前/后 翻页按钮是否需要禁止点击
264-
if (resourceCurrentPage == 1) {
265-
$(".glyphicon-chevron-left").parent().addClass('disable');
266-
// 只有一页
267-
if(resourceCurrentPage == totalPages){
268-
$(".glyphicon-chevron-right").parent().addClass('disable');
269-
}
270-
} else if (resourceCurrentPage == totalPages) {
262+
resourcesListPaging.insertBefore($("#resourcesListPaging > .pagination > li:last-child"));
263+
}
264+
//根据初始页面的设置,判断向前/后 翻页按钮是否需要禁止点击
265+
if (resourceCurrentPage == 1) {
266+
$(".glyphicon-chevron-left").parent().addClass('disable');
267+
// 只有一页
268+
if(resourceCurrentPage == totalPages){
271269
$(".glyphicon-chevron-right").parent().addClass('disable');
272270
}
273-
//为分页列表项绑定事件
274-
$('#resourcesListPaging>.pagination').delegate('.resourcesListChang', 'click', function (e) {
275-
if (resourceCurrentPage != parseInt(e.currentTarget.text)) {
276-
resourceCurrentPage = parseInt(e.currentTarget.text)
277-
paginationClick(resourceCurrentPage);
278-
}
279-
});
280-
//切换到上一页
281-
$(".glyphicon-chevron-left").parent().click(function () {
282-
resourceCurrentPage--;
283-
paginationClick(resourceCurrentPage);
284-
});
285-
//切换到下一页
286-
$(".glyphicon-chevron-right").parent().click(function () {
287-
resourceCurrentPage++;
271+
} else if (resourceCurrentPage == totalPages) {
272+
$(".glyphicon-chevron-right").parent().addClass('disable');
273+
}
274+
};
275+
function initClickEvent() {
276+
//为分页列表项绑定事件
277+
$('#resourcesListPaging>.pagination').delegate('.resourcesListChang', 'click', function (e) {
278+
if (resourceCurrentPage != parseInt(e.currentTarget.text)) {
279+
resourceCurrentPage = parseInt(e.currentTarget.text)
288280
paginationClick(resourceCurrentPage);
289-
});
281+
}
282+
});
283+
//切换到上一页
284+
$(".glyphicon-chevron-left").parent().click(function () {
285+
resourceCurrentPage--;
286+
paginationClick(resourceCurrentPage);
287+
});
288+
//切换到下一页
289+
$(".glyphicon-chevron-right").parent().click(function () {
290+
resourceCurrentPage++;
291+
paginationClick(resourceCurrentPage);
292+
});
290293
};
291294
//页面的点击事件,触发的function
292295
function paginationClick(resourceCurrentPage) {

0 commit comments

Comments
 (0)