瀏覽代碼

Merge pull request #2129 from campbell/master

Bugfix - only selected options that are not disabled should be used when initializing a dropdown
Kevin Brown 11 年之前
父節點
當前提交
b2b5ebd637
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      select2.js

+ 2 - 2
select2.js

@@ -2214,7 +2214,7 @@ 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 the selection initializer
                 // install the selection initializer
                 opts.initSelection = function (element, callback) {
                 opts.initSelection = function (element, callback) {
-                    var selected = element.find("option").filter(function() { return this.selected });
+                    var selected = element.find("option").filter(function() { return this.selected && !this.disabled });
                     // a single select box always has a value, no need to null check 'selected'
                     // a single select box always has a value, no need to null check 'selected'
                     callback(self.optionToData(selected));
                     callback(self.optionToData(selected));
                 };
                 };
@@ -2488,7 +2488,7 @@ the specific language governing permissions and limitations under the Apache Lic
 
 
                     var data = [];
                     var data = [];
 
 
-                    element.find("option").filter(function() { return this.selected }).each2(function (i, elm) {
+                    element.find("option").filter(function() { return this.selected && !this.disabled }).each2(function (i, elm) {
                         data.push(self.optionToData(elm));
                         data.push(self.optionToData(elm));
                     });
                     });
                     callback(data);
                     callback(data);