浏览代码

fix placeholder problem. fixes #853

Igor Vaynberg 12 年之前
父节点
当前提交
c081d0f00c
共有 1 个文件被更改,包括 12 次插入8 次删除
  1. 12 8
      select2.js

+ 12 - 8
select2.js

@@ -1473,14 +1473,6 @@ 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") ||
@@ -1807,6 +1799,18 @@ the specific language governing permissions and limitations under the Apache Lic
             return opts;
         },
 
+        // single
+        getPlaceholder: function() {
+            // if a placeholder is specified on a single select without the first empty option ignore it
+            if (this.select) {
+                if (this.select.find("option").first().text() !== "") {
+                    return undefined;
+                }
+            }
+
+            return this.parent.getPlaceholder.apply(this, arguments);
+        },
+
         // single
         setPlaceholder: function () {
             var placeholder = this.getPlaceholder();