您的位置:首页 > Web前端 > JavaScript

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);
}));
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  javascript