Skip to content

Commit 70873ab

Browse files
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 <option value>&nbsp;</option>, that's what Rails 3 f.select helper generate by default).
1 parent cbd2a70 commit 70873ab

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

select2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1806,7 +1806,7 @@ the specific language governing permissions and limitations under the Apache Lic
18061806
//Determine the placeholder option based on the specified placeholderOption setting
18071807
return (this.opts.placeholderOption === "first" && firstOption) ||
18081808
(typeof this.opts.placeholderOption === "function" && this.opts.placeholderOption(this.select));
1809-
} else if (firstOption.text() === "" && firstOption.val() === "") {
1809+
} else if ($.trim(firstOption.text()) === "" && firstOption.val() === "") {
18101810
//No explicit placeholder option specified, use the first if it's blank
18111811
return firstOption;
18121812
}

0 commit comments

Comments
 (0)