From dae97ffc8372287abd3158acae0307a75189e36c Mon Sep 17 00:00:00 2001 From: "Igor G." Date: Tue, 21 May 2013 17:20:24 +0300 Subject: [PATCH] Remove duplication of "No matches found" message In case if data is fetched in chunks, not at once, "No matches found" message is shown as many times as we requested for it. Lets say we have 15 items, and data is fetched 5 at a time. After all items are selected, "No matches found" message would be duplicated 3 times. --- select2.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/select2.js b/select2.js index fe4caafd..5a222427 100644 --- a/select2.js +++ b/select2.js @@ -2739,7 +2739,9 @@ 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){ - this.results.append("
  • " + self.opts.formatNoMatches(self.search.val()) + "
  • "); + if(!data || data && !data.more) { + this.results.append("
  • " + self.opts.formatNoMatches(self.search.val()) + "
  • "); + } } },