@Trevor I have fixed it works with auto “Enable Auto Count” and without it.
Code:
(() => {
const setIcons = (state) => {
if (!state.id) {
return state.text;
}
const taxononyName = state.element.value.toLowerCase();
const taxonomyText = state.text;
const item = <code><span><i class="tax-icon tax-icon--${taxononyName}"></i> ${taxonomyText}</span></code>;
let options = $(item);
return options;
};
const onSelect2Init = () => {
$('select.sf-input-select').select2({
templateResult: setIcons,
minimumResultsForSearch: -1
});
};
$(document).on('sf:init', '.searchandfilter', function () {
onSelect2Init();
});
$(document).on('sf:ajaxfinish', '.searchandfilter', function () {
onSelect2Init();
});
})();
Feel free to share this with people who need it.
Regards,
Nino