improve val() handling on multiselect. fixes #654
This commit is contained in:
parent
2f53c251d4
commit
ebc436c42b
14
select2.js
14
select2.js
@ -1932,14 +1932,13 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
|
|
||||||
if (opts.element.get(0).tagName.toLowerCase() === "select") {
|
if (opts.element.get(0).tagName.toLowerCase() === "select") {
|
||||||
// install sthe selection initializer
|
// install sthe selection initializer
|
||||||
opts.initSelection = function (element,callback) {
|
opts.initSelection = function (element, callback) {
|
||||||
|
|
||||||
var data = [];
|
var data = [];
|
||||||
element.find(":selected").each2(function (i, elm) {
|
|
||||||
data.push({id: elm.attr("value"), text: elm.text(), element: elm});
|
|
||||||
});
|
|
||||||
|
|
||||||
if ($.isFunction(callback))
|
element.find(":selected").each2(function (i, elm) {
|
||||||
|
data.push({id: elm.attr("value"), text: elm.text(), element: elm[0]});
|
||||||
|
});
|
||||||
callback(data);
|
callback(data);
|
||||||
};
|
};
|
||||||
} else if ("data" in opts) {
|
} else if ("data" in opts) {
|
||||||
@ -2410,10 +2409,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
this.setVal(val);
|
this.setVal(val);
|
||||||
|
|
||||||
if (this.select) {
|
if (this.select) {
|
||||||
this.select.find(":selected").each(function () {
|
this.opts.initSelection(this.select, this.bind(this.updateSelection));
|
||||||
data.push({id: $(this).attr("value"), text: $(this).text()});
|
|
||||||
});
|
|
||||||
this.updateSelection(data);
|
|
||||||
if (triggerChange) {
|
if (triggerChange) {
|
||||||
this.triggerChange();
|
this.triggerChange();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user