From 8f4a186ba5771ceec1d252de1249d55d3b656c6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A1=97=E5=A4=B4=E5=B0=8F=E8=B4=A9?= Date: Wed, 28 Oct 2020 21:08:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=8A=A8=E6=80=81=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/webapp/static/lib/forum/jForum.js | 34 +++++++++---------- .../static/lib/forum/jForum.pagination.js | 8 ++++- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/thrones/src/main/webapp/static/lib/forum/jForum.js b/thrones/src/main/webapp/static/lib/forum/jForum.js index ce6bfced..b7e1078d 100644 --- a/thrones/src/main/webapp/static/lib/forum/jForum.js +++ b/thrones/src/main/webapp/static/lib/forum/jForum.js @@ -44,26 +44,24 @@ define('jForum', [ var extEle = $('#page_another_navigation'); extEle.find(pnSelector).remove(); extEle.append(pageHtmlStruct); + }, + jsonCallback: function (jsonArray) { + if ($.isEmptyObject(jsonArray)) { + return; + } + var fn = template[rawdata.callFun]; + if (typeof fn === "function") { + fn.call(this, jsonArray); + } + }, + deferCallback: function(){ + var deferFun = xhrDefer[rawdata.defFun]; + if (typeof deferFun === "function") { + deferFun.call(this, xhr, template); + } } }; - paginationFunction(_pn, option).done(function (jsonArray) { - if (jQuery.isEmptyObject(jsonArray)) { - return; - } - var jsonCallFun = template[rawdata.callFun]; - if (typeof jsonCallFun === "function") { - jsonCallFun.call(this, jsonArray); - } else { - console.log('[page_navigation]json callback function:' + jsonCallFun + ' is not function or jForumXhrDefer not module'); - } - }).done(function () { - var deferFun = xhrDefer[rawdata.defFun]; - if (typeof deferFun === "function") { - deferFun.call(this, xhr, template); - } else { - console.log('[page_navigation]defer callback function:' + deferFun + ' is not function or jForumXhrDefer not module'); - } - }).fail(function () { + paginationFunction(_pn, option).fail(function () { console.log('[page_navigation] execute fail'); }); }).trigger('initDataEvent'); diff --git a/thrones/src/main/webapp/static/lib/forum/jForum.pagination.js b/thrones/src/main/webapp/static/lib/forum/jForum.pagination.js index 1f3a5199..519b11bd 100644 --- a/thrones/src/main/webapp/static/lib/forum/jForum.pagination.js +++ b/thrones/src/main/webapp/static/lib/forum/jForum.pagination.js @@ -63,6 +63,9 @@ define('jForumPagination', [ // a=总页数 var b = _curIns._calc(response.page, a); _curIns.render(b.start, b.end, response.page, a, jqEle); + if ($.isFunction(_curIns.config.jsonCallback)) { + _curIns.config.jsonCallback(response.result); + } //滚动到顶部 $('html, body').animate({ scrollTop: 0 }, 500); _curIns.defer.resolve(response.result); @@ -84,6 +87,9 @@ define('jForumPagination', [ } //记入历史 recordHistory(page, postData.pageSize); + if ($.isFunction(_curIns.config.deferCallback)) { + _curIns.config.deferCallback(); + } console.log('[pagination] ajax is complete'); }; $.ajax(formatAjaxParams); @@ -242,4 +248,4 @@ define('jForumPagination', [ return Page; })(); return jForumPagination; -}); \ No newline at end of file +}); -- GitLab