Parcourir la source

always show spinner during searching. fixes #950 fixes #943

Igor Vaynberg il y a 12 ans
Parent
commit
dd34cc5d67
1 fichiers modifiés avec 6 ajouts et 5 suppressions
  1. 6 5
      select2.js

+ 6 - 5
select2.js

@@ -1356,8 +1356,6 @@ the specific language governing permissions and limitations under the Apache Lic
                 return;
                 return;
             }
             }
 
 
-            search.addClass("select2-active");
-
             function postRender() {
             function postRender() {
                 results.scrollTop(0);
                 results.scrollTop(0);
                 search.removeClass("select2-active");
                 search.removeClass("select2-active");
@@ -1386,9 +1384,6 @@ the specific language governing permissions and limitations under the Apache Lic
                 }
                 }
                 return;
                 return;
             }
             }
-            else if (opts.formatSearching() && initial===true) {
-                render("<li class='select2-searching'>" + opts.formatSearching() + "</li>");
-            }
 
 
             if (opts.maximumInputLength && search.val().length > opts.maximumInputLength) {
             if (opts.maximumInputLength && search.val().length > opts.maximumInputLength) {
                 if (checkFormatter(opts.formatInputTooLong, "formatInputTooLong")) {
                 if (checkFormatter(opts.formatInputTooLong, "formatInputTooLong")) {
@@ -1399,6 +1394,12 @@ the specific language governing permissions and limitations under the Apache Lic
                 return;
                 return;
             }
             }
 
 
+            if (opts.formatSearching && this.findHighlightableChoices().length === 0) {
+                render("<li class='select2-searching'>" + opts.formatSearching() + "</li>");
+            }
+
+            search.addClass("select2-active");
+
             // give the tokenizer a chance to pre-process the input
             // give the tokenizer a chance to pre-process the input
             input = this.tokenize();
             input = this.tokenize();
             if (input != undefined && input != null) {
             if (input != undefined && input != null) {