While in the midst of implementing a loading route for use while awaiting certain ajax calls a fun easter egg fell in my lap.
Just by creating a loading_route.js, which contains
App.LoadingRoute = Ember.Route.extend({});
and a loading.hbs (my loading template), which contains, just some boring css with a spinner
<div class="loading_content_wrapper"></div>
Ember has this fun loading state (enterLoadingState) where while it’s loading the models and setting up the controllers for the first time (I think it’s just the first time, I haven’t witnessed it anywhere else) it will go to the loading route and hang out there. That way the user can watch a fun spinning circle instead of a white page. Cool stuff! Thanks Tom/Yehuda/whoever put that code in there (I’m too lazy to check the history).
And how can you style/position the loading indicator properly?
As soon as I used position: fixed or anything like that to put it into the center, the loading indicator does not disappear anymore.
This will be in the docs after my commit goes through, but you can override the renderTemplate method of the LoadingRoute to render it into a specific outlet.
I tried several times but it didn’t work. Here is gist of my app.js and the template. in the JS if I uncomment the commented part then it works. Maybe I’m missing something I’m not aware of. https://gist.github.com/Omnipresent/6302024