/    Sign up×
Community /Pin to ProfileBookmark

Select2 Finished Loading

I’m using Select2 data array as a source

https://select2.org/

https://select2.org/data-sources/arrays

Is there a way of running a script when this has finished loading and doing it’s thing.

I want to hide a loading icon when it’s completed.

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumJan 06.2022 — @kiwis80#1641169 The docs say:
>Unlike the case of items supplied by AJAX data sources, items supplied as an array will be immediately rendered as <option> elements in the target <select> control.

Therefore it would not make sense to display a loading icon. However you might do this for the complete page and hide it by the load event.
Copy linkTweet thisAlerts:
@kiwisauthorJan 06.2022 — I'm applying the styling and list to numerous select elements. So I think it 'loads' quickly but takes a while for the browser to render it all correctly (if that's the correct term).

Is there a way to hide a loading box AFTER that's been done?
Copy linkTweet thisAlerts:
@SempervivumJan 06.2022 — @kiwis80#1641199
>So I think it 'loads' quickly but takes a while for the browser to render it all correctly (if that's the correct term).

Is this just an assumption or did you encounter issues like flickering or skipping?

I recommend to hide the loading box after the initializing all of the selects.
Copy linkTweet thisAlerts:
@kiwisauthorJan 06.2022 — @Sempervivum#1641202

I'm just assuming. The select boxes show small while the browser loader is doing it's thing then bang it kick into gear and adjusts the size and it's complete.
Copy linkTweet thisAlerts:
@SempervivumJan 07.2022 — As recommended before try to hide the loading box by the "load" event of the page.
×

Success!

Help @kiwis spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...