From 70873abe9d89c931b1716e78b0d639cad1cadf49 Mon Sep 17 00:00:00 2001 From: pineapple-thief Date: Fri, 28 Mar 2014 15:45:38 +1100 Subject: [PATCH] Update select2.js Fixes unpleasant glitch where initializing select2 on select where first input option tag has non-breakable space in innerText causes selected option to be displayed as "undefined" until user changes selection. (i.e. HTML was like , that's what Rails 3 f.select helper generate by default). --- select2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/select2.js b/select2.js index ea5c902b..3beb6420 100644 --- a/select2.js +++ b/select2.js @@ -1806,7 +1806,7 @@ the specific language governing permissions and limitations under the Apache Lic //Determine the placeholder option based on the specified placeholderOption setting return (this.opts.placeholderOption === "first" && firstOption) || (typeof this.opts.placeholderOption === "function" && this.opts.placeholderOption(this.select)); - } else if (firstOption.text() === "" && firstOption.val() === "") { + } else if ($.trim(firstOption.text()) === "" && firstOption.val() === "") { //No explicit placeholder option specified, use the first if it's blank return firstOption; }