1
0
mirror of synced 2024-11-26 14:56:07 +03:00

fix #1404 allow formatnomatches to be null in multiselects

This commit is contained in:
Igor Vaynberg 2013-06-13 20:48:48 -07:00
parent 48294f2aea
commit c36b53ad24

View File

@ -543,7 +543,7 @@ the specific language governing permissions and limitations under the Apache Lic
function checkFormatter(formatter, formatterName) { function checkFormatter(formatter, formatterName) {
if ($.isFunction(formatter)) return true; if ($.isFunction(formatter)) return true;
if (!formatter) return false; 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) { 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 all results are chosen render formatNoMAtches
if(!this.opts.createSearchChoice && !choices.filter('.select2-result:not(.select2-selected)').length > 0){ 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) { 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>"); if (checkFormatter(self.opts.formatNoMatches, "formatNoMatches")) {
this.results.append("<li class='select2-no-results'>" + self.opts.formatNoMatches(self.search.val()) + "</li>");
}
} }
} }