From c36b53ad2424e035cd9f4d387e5bc54842413976 Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Thu, 13 Jun 2013 20:48:48 -0700 Subject: [PATCH] fix #1404 allow formatnomatches to be null in multiselects --- select2.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/select2.js b/select2.js index b342164c..c12761d3 100644 --- a/select2.js +++ b/select2.js @@ -543,7 +543,7 @@ the specific language governing permissions and limitations under the Apache Lic function checkFormatter(formatter, formatterName) { if ($.isFunction(formatter)) return true; if (!formatter) return false; - throw new Error("formatterName must be a function or a falsy value"); + throw new Error(formatterName +" must be a function or a falsy value"); } function evaluate(val) { @@ -2814,7 +2814,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){ if(!data || data && !data.more && this.results.find(".select2-no-results").length === 0) { - this.results.append("
  • " + self.opts.formatNoMatches(self.search.val()) + "
  • "); + if (checkFormatter(self.opts.formatNoMatches, "formatNoMatches")) { + this.results.append("
  • " + self.opts.formatNoMatches(self.search.val()) + "
  • "); + } } }