Skip to content

Commit 2a4e026

Browse files
committed
Bugfix - only selected options that are not disabled should be used when initializing the dropdown
1 parent 0636e42 commit 2a4e026

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

select2.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,7 +2214,7 @@ the specific language governing permissions and limitations under the Apache Lic
22142214
if (opts.element.get(0).tagName.toLowerCase() === "select") {
22152215
// install the selection initializer
22162216
opts.initSelection = function (element, callback) {
2217-
var selected = element.find("option").filter(function() { return this.selected });
2217+
var selected = element.find("option").filter(function() { return this.selected && !this.disabled });
22182218
// a single select box always has a value, no need to null check 'selected'
22192219
callback(self.optionToData(selected));
22202220
};
@@ -2488,7 +2488,7 @@ the specific language governing permissions and limitations under the Apache Lic
24882488

24892489
var data = [];
24902490

2491-
element.find("option").filter(function() { return this.selected }).each2(function (i, elm) {
2491+
element.find("option").filter(function() { return this.selected && !this.disabled }).each2(function (i, elm) {
24922492
data.push(self.optionToData(elm));
24932493
});
24942494
callback(data);

0 commit comments

Comments
 (0)