From 2a4e026b4908e183d108445877c9192659f9be5a Mon Sep 17 00:00:00 2001
From: Pete Campbell <pete@sumirolabs.com>
Date: Mon, 17 Feb 2014 21:16:26 -0500
Subject: [PATCH] Bugfix - only selected options that are not disabled should
 be used when initializing the dropdown

---
 select2.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/select2.js b/select2.js
index fdd18a71..29dde5ea 100644
--- a/select2.js
+++ b/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") {
                 // install the selection initializer
                 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'
                     callback(self.optionToData(selected));
                 };
@@ -2488,7 +2488,7 @@ the specific language governing permissions and limitations under the Apache Lic
 
                     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));
                     });
                     callback(data);