Skip to content

Commit c081d0f

Browse files
committed
fix placeholder problem. fixes select2#853
1 parent 244ba1b commit c081d0f

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

select2.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,14 +1473,6 @@ the specific language governing permissions and limitations under the Apache Lic
14731473

14741474
// abstract
14751475
getPlaceholder: function () {
1476-
1477-
// if a placeholder is specified on a select without the first empty option ignore it
1478-
if (this.select) {
1479-
if (this.select.find("option").first().text() !== "") {
1480-
return undefined;
1481-
}
1482-
}
1483-
14841476
return this.opts.element.attr("placeholder") ||
14851477
this.opts.element.attr("data-placeholder") || // jquery 1.4 compat
14861478
this.opts.element.data("placeholder") ||
@@ -1807,6 +1799,18 @@ the specific language governing permissions and limitations under the Apache Lic
18071799
return opts;
18081800
},
18091801

1802+
// single
1803+
getPlaceholder: function() {
1804+
// if a placeholder is specified on a single select without the first empty option ignore it
1805+
if (this.select) {
1806+
if (this.select.find("option").first().text() !== "") {
1807+
return undefined;
1808+
}
1809+
}
1810+
1811+
return this.parent.getPlaceholder.apply(this, arguments);
1812+
},
1813+
18101814
// single
18111815
setPlaceholder: function () {
18121816
var placeholder = this.getPlaceholder();

0 commit comments

Comments
 (0)