From 2ae7f647081fd4e1c44546931a66b37216ab6333 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 10 Mar 2025 22:33:30 +0700 Subject: [PATCH] Add support for templates in the selectedOptions parameter Add support for templates in the selectedOptions parameter. You can now use templates in the settings as follows: $('.multiselect-element').multiselect({ texts: { selectedOptions: 'Selected: #cnt#', } }); --- jquery.multiselect.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jquery.multiselect.js b/jquery.multiselect.js index 0295ed1..fa91734 100644 --- a/jquery.multiselect.js +++ b/jquery.multiselect.js @@ -867,7 +867,11 @@ } // if copy is larger than button width use "# selected" else if( !instance.options.showAllPlaceholderOpts && instance.options.replacePlaceholderText && ((placeholderTxt.width() > placeholder.width()) || (selOpts.length != selectVals.length)) ) { - placeholderTxt.text( selectVals.length + instance.options.texts.selectedOptions ); + if (instance.options.texts.selectedOptions.indexOf('#cnt#') !== -1) { + placeholderTxt.text(instance.options.texts.selectedOptions.replace('#cnt#', selectVals.length)); + } else { + placeholderTxt.text(selectVals.length + instance.options.texts.selectedOptions); + } } },