Browse Source

remove dupe format no matches messages. fixes #1341

Igor Vaynberg 12 years ago
parent
commit
f1a5fe2c9e
1 changed files with 4 additions and 2 deletions
  1. 4 2
      select2.js

+ 4 - 2
select2.js

@@ -1571,7 +1571,9 @@ the specific language governing permissions and limitations under the Apache Lic
                 }
 
                 if (data.results.length === 0 && checkFormatter(opts.formatNoMatches, "formatNoMatches")) {
-                    render("<li class='select2-no-results'>" + opts.formatNoMatches(search.val()) + "</li>");
+                    if (results.find(".select2-no-results").length === 0) {
+                        render("<li class='select2-no-results'>" + opts.formatNoMatches(search.val()) + "</li>");
+                    }
                     return;
                 }
 
@@ -2755,7 +2757,7 @@ the specific language governing permissions and limitations under the Apache Lic
 
             //If all results are chosen render formatNoMAtches
             if(!this.opts.createSearchChoice && !choices.filter('.select2-result:not(.select2-selected)').length > 0){
-            	if(!data || data && !data.more) {
+            	if(!data || data && !data.more && this.results.find(".select2-no-results").length === 0) {
             	    this.results.append("<li class='select2-no-results'>" + self.opts.formatNoMatches(self.search.val()) + "</li>");
             	}
             }