select2
2015-07-14 16:28
561 查看
$('input.professionUserSelect2').each(this.proxy(function(k,v){ var id = parseInt($(v).attr("data-id")); $(v).select2({ placeholder: "请选择...", allowClear: true, multiple : true, ajax: { url: $.u.config.constant.smsqueryserver, type: "post", data: this.proxy(function(term, page){ return { "tokenid": $.cookie("tokenid"), "method": "getGradeOneAuditors", "term": term, "professionId": id, "taskId": this._wkid, "start": (page - 1) * this._SELECT2_PAGE_LENGTH, "length": this._SELECT2_PAGE_LENGTH }; }), results: this.proxy(function(response, page){ if(response.success){ return { "results": response.data.aaData, "more": response.data.iTotalRecords > (page * this._SELECT2_PAGE_LENGTH) }; } }) }, formatSelection: function(item){ return item.fullname; }, formatResult: function(item){ return item.fullname; } }).on("select2-selecting", this.proxy(function(e) { var value = this.member.select2("val"); value.push(e.object.fullname); this.member.select2("val",value); })) .on("select2-removing", this.proxy(function(e) { var value = this.member.select2("val"); var index = value.indexOf(e.choice.fullname); if(index > -1){ value.splice(index,1); this.member.select2("val",value); } })); $(v).select2("enable", false); }));
相关文章推荐
- JQuery1——基础($对象,选择器,对象转换)
- Android学习笔记(二九):嵌入浏览器
- Android java 与 javascript互访(相互调用)的方法例子
- JavaScript演示排序算法
- javascript实现10进制转为N进制数
- 2019年开发人员应该学习的8个JavaScript框架
- HTML中的script标签研究
- 异步流程控制:7 行代码学会 co 模块
- JavaScript拆分字符串时产生空字符的原因
- IE8开发人员工具教程(二)
- 在flex中执行一个javascript方法的简单方式
- Flex结合JavaScript读取本地路径的方法
- PowerShell中执行Javascript的方法示例
- javascript asp教程第六课-- response方法
- javascript asp教程More About Recordsets
- javascript asp教程第十二课---session对象
- javascript asp教程创建数据库连接
- javascript asp教程错误处理
- javascript asp教程第十课--global asa