Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

Support for loading and searching dropdown items via ajax #36

Open
aszenz opened this issue May 4, 2021 · 2 comments
Open

Support for loading and searching dropdown items via ajax #36

aszenz opened this issue May 4, 2021 · 2 comments

Comments

@aszenz
Copy link

aszenz commented May 4, 2021

Thanks for creating this package.

I would like to know if there's a way to load items lazily via ajax requests, we have drop-downs with hundreds of items that cannot be preloaded.

On a related note it would be great if searching could also be done via ajax requests.

The best example of this currently is jQuery based select2 and react based react-select.

@PedroHLC
Copy link
Contributor

PedroHLC commented May 10, 2021

I would like to know if there's a way to load items lazily via ajax requests

You can use anything that can transform into an array of objects, but I would recommend showing a spinner when loading the data, approaching a state-machine like this: http://blog.jenkster.com/2016/06/how-elm-slays-a-ui-antipattern.html

If searching could also be done via ajax requests.

Right now search is done by filtering locally, we can accept that as a feature if someone is interested in submitting a PR.

EDIT: For reference: https://package.elm-lang.org/packages/PaackEng/elm-ui-dropdown/latest/Dropdown#filterable

@aszenz
Copy link
Author

aszenz commented May 18, 2021

You can use anything that can transform into an array of objects, but I would recommend showing a spinner when loading the data, approaching a state-machine like this: http://blog.jenkster.com/2016/06/how-elm-slays-a-ui-antipattern.html

So when it's a big drop down list I can't get an array of objects all at once, ideally i would load 10 options, show them when the user opens the drop down and then once the user scrolls past these 10 options, load 10 more and so on.
This will require a paginated api, to which the drop down can send commands to. Similarly filtering would work based on an api.

Admittedly this is a complex requirement but it's been implemented before in elm by https://github.com/MadonnaMat/elm-select-two

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants