jie
jie
  • 发布:2015-03-10 14:29
  • 更新:2015-03-10 21:59
  • 阅读:4497

mui 上拉刷新完成判断

分类:MUI

我想让 i>j 的时候显示“没有更多数据了”,mui('#pullrefresh').pullRefresh().endPullupToRefresh() 这串代码中的判断语句该怎么写呢?

function pullupRefresh() {  
                setTimeout(function() {  
                    mui('#pullrefresh').pullRefresh().endPullupToRefresh(); //参数为true代表没有更多数据了。  
                    var table = document.body.querySelector('.mui-table-view');  
                    var cells = document.body.querySelectorAll('.mui-table-view-cell');  
                    mui.ajax({  
                        type: 'GET',  
                        dataType: 'json',  
                        data: {},  
                        url: 'http://www.xinfagc.com:8080/marketitem',  
                        success: function(goods) {  
                            goods = JSON.stringify(goods);  
                            var j = eval(goods).length;  
                            var i = cells.length;  
                            var len = 0;  
                            if (i < j) {  
                                for (len = i + 5; i < len; i++) {  
                                    var li = document.createElement('li');  
                                    li.className = 'mui-table-view-cell';  
                                    li.setAttribute('gc_id', eval(goods)[i].id);  
                                    li.innerHTML = '<img class="mui-media-object mui-pull-left" src="'+ eval(goods)[i].goods_img+'"><div class="mui-media-body"><p class="mui-ellipsis3">' + eval(goods)[i].goods_name + '</p><p class="mui-ellipsis">佣金: &yen' + eval(goods)[i].goods_comm_fixed + '</p><p class="mui-ellipsis2">现价:&yen' + eval(goods)[i].goods_price + '</p></div><div class="mui-button-dis"><button class="dis-button1">查看详情</button><button class="dis-button2">我要分销</button></div>';  
                                    table.appendChild(li);  
                                }  
                            }  
                        }  
                    });               
                }, 1000);  
            }
2015-03-10 14:29 负责人:无 分享
已邀请:
DCloud_UNI_FXY

DCloud_UNI_FXY

mui('#pullrefresh').pullRefresh().endPullupToRefresh(i>j);
  • jie (作者)

    提示错误:Uncaught ReferenceError: i is not defined at templates/distribution_list_compre.html:46

    2015-03-10 14:48

  • DCloud_UNI_FXY

    我只是给你演示了下怎么显示没有更多数据了。


    你的代码本来就是不对的。

    1.不应该setTimeout

    2.mui('#pullrefresh').pullRefresh().endPullupToRefresh(); 应该在ajax的success里边调用




    1. if (i < j) {

      //其他代码

      mui('#pullrefresh').pullRefresh().endPullupToRefresh();

      }else{

      mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);

      }



    2015-03-10 15:10

酷

大哥,求救 怎么在服务器配置这个啊? “http://www.xinfagc.com:8080/marketitem” 是要在服务器弄什么api的吗?

该问题目前已经被锁定, 无法添加新回复