Lazy loading for Select form component options

Hey there! Is anyone aware of a way to lazy load the options of a Select form component? Right now I've added the Select dropdown to a table action modal window. The request for the options is done while loading the table which is sub-optimal as it will fire 25 requests (current items per page set to 25) during the initial load and on every page switch. I'd love to load the options for the Select component only right before it's being displayed to the user (eg. after clicking on the action button for the record and when the modal window is shown). Thank you very much! Best wishes Tom
Solution:
I think I found a way... (the returned array is the replacement for a method call that I have in my code, to simplify things) Specifying the options using an inline function callback triggers the callback immediately: ``` ->options(fn():array => ['1', '2', '3'])...
Jump to solution
1 Reply
Solution
tom hatzer
tom hatzer6mo ago
I think I found a way... (the returned array is the replacement for a method call that I have in my code, to simplify things) Specifying the options using an inline function callback triggers the callback immediately:
->options(fn():array => ['1', '2', '3'])
->options(fn():array => ['1', '2', '3'])
Specifying the options using a regular function definition only triggers the call when the modal is opened and the Select component is shown
->options(function() {
return ['1', '2', '3'];
})
->options(function() {
return ['1', '2', '3'];
})
Want results from more Discord servers?
Add your server