瀏覽代碼

fix firefox caret bug. closes #153

Igor Vaynberg 13 年之前
父節點
當前提交
83c11b27df
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      select2.js

+ 4 - 2
select2.js

@@ -476,7 +476,7 @@
 
             installKeyUpChangeEvent(search);
             search.bind("keyup-change", this.bind(this.updateResults));
-            search.bind("focus", function () { search.addClass("select2-focused");});
+            search.bind("focus", function () { search.addClass("select2-focused"); search.val(""); });
             search.bind("blur", function () { search.removeClass("select2-focused");});
 
             this.dropdown.delegate(resultsSelector, "click", this.bind(function (e) {
@@ -1527,7 +1527,9 @@
                 // stretch the search box to full width of the container so as much of the placeholder is visible as possible
                 this.search.width(this.getContainerWidth());
             } else {
-                this.search.val("").width(10);
+                // we set this to " " instead of "" and later clear it on focus() because there is a firefox bug
+                // that does not properly render the caret when the field starts out blank
+                this.search.val(" ").width(10);
             }
         },