1
0
mirror of synced 2024-11-24 22:06:07 +03:00

support removing elements that have non-numeric ids

This commit is contained in:
Igor Vaynberg 2012-03-26 23:45:08 -07:00
parent 339c7a850e
commit b18b9aecd8

View File

@ -65,6 +65,24 @@
} }
}; };
function indexOf(value, array) {
var i = 0, l = array.length, v;
if (value.constructor === String) {
for (; i < l; i++) if (value.localeCompare(array[i]) === 0) return i;
} else {
for (; i < l; i++) {
v = array[i];
if (v.constructor === String) {
if (v.localeCompare(value) === 0) return i;
} else {
if (v === value) return i;
}
}
}
return -1;
}
function getSideBorderPadding(element) { function getSideBorderPadding(element) {
return element.outerWidth() - element.width(); return element.outerWidth() - element.width();
} }
@ -970,7 +988,7 @@
throw "Invalid argument: " + selected + ". Must be .select2-search-choice"; throw "Invalid argument: " + selected + ". Must be .select2-search-choice";
} }
index = val.indexOf(selected.data("select2-data").id); index = indexOf(selected.data("select2-data").id, val);
if (index >= 0) { if (index >= 0) {
val.splice(index, 1); val.splice(index, 1);