J4 - choices.js instance

336 views
Skip to first unread message

Joomla Eye

unread,
Oct 18, 2021, 10:36:05 AM10/18/21
to Joomla! General Development
Hello!
I am implementing Joomla 4 custom component and in which i have form fields with layout="joomla.form.field.list-fancy-select" which uses library https://github.com/Choices-js/Choices

i have added one checkbox to select/deselect all options besides one of the field as Choices does not have select/deselect all feature.


As per that i need instance of fancy select which i am unable to get from library. can you please suggest me what options do we have to get specific instance of select box.

Thanks
choices-dropdown-select-deselect-options-using-checkbox.png

Fedir

unread,
Oct 19, 2021, 10:40:09 AM10/19/21
to Joomla! General Development
You can access with `choicesInstance` property of the `joomla-field-fancy-select` field, eg:
$fieldContainer.querySelector('joomla-field-fancy-select').choicesInstance

понеділок, 18 жовтня 2021 р. о 17:36:05 UTC+3 joom...@gmail.com пише:

Joomla Eye

unread,
Oct 20, 2021, 6:06:04 AM10/20/21
to Joomla! General Development
Thank you so much for response.
I have used:
const field = document.getElementById('jform_tags').closest('joomla-field-fancy-select');
const select = field.choicesInstance;

Reply all
Reply to author
Forward
0 new messages