为了账号安全,请及时绑定邮箱和手机立即绑定

select2如何触发下拉事件?

select2如何触发下拉事件?

空麻袋背米 2016-05-26 19:04:36
<select class="select2" id="customer" style="width:78%;" onscroll="customerScroll()">    var pageSize = 50;     var customerLoadOrNo = true;     $.post("customer/ownerCustomer", null, function(rst) {         if (rst.customers) {             customerList = rst.customers;             $(function(){                     //初始化加载一定数量的选项                     for(var i=0;i<pageSize;i++){                         if(customerList[i]){                             var key = customerList[i].id + "," + HandleSpaceToZero(customerList[i].mileage) + "," + HandleSpaceToStr(customerList[i].brand) + " "                                     + HandleSpaceToStr(customerList[i].model);                             var value = customerList[i].customerName + "," + customerList[i].plateNo + ","                                     +  HandleSpaceToStr(customerList[i].mobile) + "," +  HandleSpaceToStr(customerList[i].cardNo);                             optionStr += "<option value='" + key + "'>" + value                                     + "</option>";                         }else{                             break;                         }                     }                     $("#customer").append(optionStr);             });                              return initSelect(rst.customers);         }     }, "json");          function customerScroll(){                            var vst = parseInt($('#customer')[0].scrollTop);                     var vsh =  parseInt($('#customer')[0].scrollHeight);                     var vch =  parseInt($('#customer')[0].clientHeight);                     var len =  $('#customer option').length;                     //如果下拉到底,判断是否要继续加载                     if((vst + vch == vsh) && loadOrNo){                             //这里可以异步取数据,根据返回结果判断是否继续加载                             if(len > rst.customers.length()){                                     customerLoadOrNo = false;                                 }                             for(var i=len+1;i<len+pageSize;i++){                                 if(rst.customers[i]){                                     var key = customer.id + "," + HandleSpaceToZero(customer.mileage) + "," + HandleSpaceToStr(customer.brand) + " "                                             + HandleSpaceToStr(customer.model);                                     var value = customer.customerName + "," + customer.plateNo + ","                                             +  HandleSpaceToStr(customer.mobile) + "," +  HandleSpaceToStr(customer.cardNo);                                     optionStr += "<option value='" + key + "'>" + value                                             + "</option>";                                 }else{                                     break;                                 }                             }                             $("#customer").append(optionStr);                     }     }现在的问题是无法触发customerScroll()方法,该怎么解决,求大神们指导!感恩!
查看完整描述

1 回答

?
Suber丶林

TA贡献75条经验 获得超180个赞

select标签,用的是change事件。

查看完整回答
1 反对 回复 2016-06-29
  • 1 回答
  • 0 关注
  • 7406 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信