From a19e33e3af31c6e87846fb8ac1f585f44f0c82d3 Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Fri, 1 Feb 2013 10:46:40 -0800 Subject: [PATCH] ignore configured placeholder on selects without first empty option. fixes #785 --- select2.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/select2.js b/select2.js index 9fe484f6..4766e590 100644 --- a/select2.js +++ b/select2.js @@ -836,7 +836,6 @@ the specific language governing permissions and limitations under the Apache Lic this.opts.element.blur(); }, - // abstract enable: function() { if (this.enabled) return; @@ -1351,6 +1350,14 @@ the specific language governing permissions and limitations under the Apache Lic // abstract getPlaceholder: function () { + + // if a placeholder is specified on a select without the first empty option ignore it + if (this.select) { + if (this.select.find("option").first().text() !== "") { + return undefined; + } + } + return this.opts.element.attr("placeholder") || this.opts.element.attr("data-placeholder") || // jquery 1.4 compat this.opts.element.data("placeholder") ||