LxZerro
LxZerro

Reputation: 3

need to display Loader Div on before pagerender in meteor/blaze/Flowrouter

i have started using meteor/blaze/FlowRouter recently and stuck on one issue

i need to display my custom loader div which will be shown whenever page template is in transition mode like loading content or requesting data from api or search users data etc

is there any way do to it in one place ? ... i don't want to add html content of loader in every page and handle it by function calling as it will be repetition of code

Upvotes: 0

Views: 102

Answers (1)

You can use percolate:momentum package from atmosphere.

First, install momentum:

meteor add percolate:momentum

Then, create a layout template:

<template name="appBody">
    {{#momentum plugin="fade"}}
        {{#if Template.subscriptionsReady}}
            {{> Template.dynamic template=main}}
        {{else}}
            {{> AppLoading}}
        {{/if}}
    {{/momentum}}
</template>

If your subscriptions is ready, then Blaze will render template {main} specified in router. Otherwise, will render your AppLoading Template.

And you need to create the AppLoading template too:

<template name="AppLoading">
    <!-- Your Loading div here -->
</template>

Upvotes: 0

Related Questions