|
楼主 |
发表于 2016-7-6 23:17:00
|
显示全部楼层
已完成分页优化,其他暂没有完成,但里面处理分页的代码和方案很值得学下,
- Model.prototype.dataDetailCustomRefresh = function(event) {
- var data = event.source;
- if (!this._id) {
- event.cancel = true;
- data.clear();
- return;
- }
-
-
- var limit = event.limit;
- var page = Math.ceil(event.offset / event.limit) + 1;
- $.ajax({
- type : 'GET',
- url : "https://nutz.cn/yvr/api/v1/topic/" + this._id,
- data : {
- page : page,
- limit : limit
- },
- success : function(result) {
- var datas = result.data.replies;
- for (var i = 0; i < datas.length; i++) {
- var row = datas[i];
- row.avatar_url = row.author.avatar_url;
- row.loginname = row.author.loginname;
- }
- data.loadData(datas, event.options.append);
- if (limit > datas.length) {
- data.setTotal(data.getCount());
- } else {
- data.setTotal(data.getCount() + 1);
- }
- }
- });
- };
复制代码
nutz-app.zip
(2.81 KB, 下载次数: 117)
|
|