A way to completely reset the selector #473
FurmigaHumana
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently there is no simple way to remove all options and put the selector back into an empty state, this could be very useful in places where the selector contents depends on some other data, like a simple city - state selector, every time you change the state the city list must be reset.
It is easy enough to remove all contents, but doing so breaks the "preload" function and the virtual_scroll plugin also wont go back to first page, this is all doable fairly easily, but would be good to have official support
`
const _tomselect = element.tomselect;
_tomselect.close(); // closes dropdown
_tomselect.clear(); // clear selected
_tomselect.clearOptions(); // clear options
_tomselect.getUrl(Math.random()); // forces virtual_scroll to go back to first page
_tomselect.wrapper.classList.remove('preloaded'); // force selector to load again
`
Beta Was this translation helpful? Give feedback.
All reactions