support id() and text() functions of select2, see

This commit is contained in:
vitalets
2013-06-26 10:26:49 +04:00
parent 2c678a10ae
commit e6ac02124c
3 changed files with 23 additions and 10 deletions

@ -139,7 +139,10 @@
return [];
}
valueProp = valueProp || 'value';
if (typeof(valueProp) !== "function") {
var idKey = valueProp || 'value';
valueProp = function (e) { return e[idKey]; };
}
var isValArray = $.isArray(value),
result = [],
@ -151,11 +154,11 @@
} else {
/*jslint eqeq: true*/
if(isValArray) {
if($.grep(value, function(v){ return v == (o && typeof o === 'object' ? o[valueProp] : o); }).length) {
if($.grep(value, function(v){ return v == (o && typeof o === 'object' ? valueProp(o) : o); }).length) {
result.push(o);
}
} else {
if(value == (o && typeof o === 'object' ? o[valueProp] : o)) {
if(value == (o && typeof o === 'object' ? valueProp(o) : o)) {
result.push(o);
}
}