From 5762b85dd2a7cda5867355f28f07ac0646001070 Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Tue, 7 May 2013 12:39:05 -0700 Subject: [PATCH] prevent opening of a disabled select via api. fixes #1272 --- select2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/select2.js b/select2.js index 8700c1de..dd9ed6dc 100644 --- a/select2.js +++ b/select2.js @@ -963,8 +963,6 @@ the specific language governing permissions and limitations under the Apache Lic // sync enabled state - //console.log("sync enabled: ", this._enabled, "readonly: ", this._readonly); - var disabled = el.prop("disabled"); if (disabled === undefined) disabled = false; this.enable(!disabled); @@ -1161,6 +1159,8 @@ the specific language governing permissions and limitations under the Apache Lic if (this.opened()) return false; + if (this._enabled === false || this._readonly === true) return false; + event = $.Event("select2-opening"); this.opts.element.trigger(event); return !event.isDefaultPrevented();