Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Lazy options loading! #1174

Open
erobwen opened this issue Sep 1, 2015 · 15 comments
Open

Lazy options loading! #1174

erobwen opened this issue Sep 1, 2015 · 15 comments

Comments

@erobwen
Copy link

erobwen commented Sep 1, 2015

Hi, this is more of an open question and a feature request, rather than an "issue report".

What I would like is a way to lazily load all of the select options the first time when the user opens up the menu. Initially there is only one single preselected item, or a text in the select-box, and when the user clicks the dropdown open, a spinner appears as options are loaded.

I have searched the web for solutions for this, but found non satisfactory. I have thought of various ways to do this, but I understand it might even be tricky to listen to the open event from the ui-select. (there are some far fetched solutions for this I found). And If I am to populate the "unloaed" option list with a single non-selectable spinner option, I dont know how to swap it for the real option list once the loading is complete. My attempts at combining ng-if or ng-show with ui-select-choices did not turn out well.

So I am pretty much stuck here.

Does anyone have a workaround for this. But perhaps even better, if ui-select could support this out of the box, it would be even better.

@vnod-ideas2it
Copy link

+1

3 similar comments
@ghost
Copy link

ghost commented Sep 9, 2015

+1

@Untit1ed
Copy link

+1

@zamabraga
Copy link

+1

@natwallbank
Copy link

+1. Has anyone found any useful workarounds in the meantime? I've just had a requirement for this where we have lots of filters (ui-select elements) on a single page but very few will be used per request. It's wasteful to load the values for these filters until they're actually used.

@erikdubbelboer
Copy link
Contributor

It's very easy to do this yourself using the refresh function. It's important to set refresh-delay to 0 so the function is called immediately when the users clicks the menu.

@natwallbank
Copy link

Isn't refresh called as the control renders, with refresh-delay simply affecting how quickly? My testing seemed to confirm that..

@erikdubbelboer
Copy link
Contributor

My mistake, you're right. I have removed my answer not to confuse people skimming thought the issue.

@mkrijtenberg
Copy link

+1

@sandro1111
Copy link

+1

1 similar comment
@mjeson
Copy link

mjeson commented Sep 20, 2016

+1

@Poltuu
Copy link

Poltuu commented Oct 12, 2016

That would be much appreciated indeed !

@HDaghash
Copy link

+1

@radyz
Copy link

radyz commented Nov 5, 2016

I think this would solve your issue wiki, so you would pass the initial data when rendered the first time and then your open-close callback would fetch the data from the server.

@Jefiozie
Copy link
Contributor

As the PR #1845 is merged please verify if it fix your problem.

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

No branches or pull requests