Forums › Forums › Search & Filter Pro › How to use Select2 options and disabled default styling?
Tagged: js
- This topic has 14 replies, 2 voices, and was last updated 4 years, 1 month ago by Anonymous.
-
Anonymous(Private) October 5, 2020 at 2:36 pm #261887
@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,
NinoTrevor(Private) October 5, 2020 at 3:09 pm #261898sf:ajaxformfinish
triggers after Auto Count andsf:ajaxfinish
triggers after an Ajax submission.There are examples of usage in the links I gave, and in an earlier reply I gave. You would need to re-apply anything you had already done on page load.
-
AuthorPosts