Hi,
I need to show more “shops” on site when you click button. All data needed are already on client and it works.
But it take some time when rendering 130 <li>
with template and some helpers per template etc.
I want to provide some feedback to user so show spinner.
Currently I am doing it this way, as I want spinner to stop when all will be rendered.
So I created my block template - stopSpinner, to which I paste parent function which set reactive var to false.
And in Template.stopSpinner.onRendered I call that function - which react by turning spinner off.
{{#if isThereMoreShops}}
<button class="btn" data-more-shops>
Zobraziť viac obchodov ( {{shopFeedLength}} )
{{#stopSpinner stopSpin=stopSpin}}
{{#if showSpinner}}
Spinner
{{/if}}
{{/stopSpinner}}
</button>
{{/if}}
{{#if isAlreadyExtended}}
<button class="btn" data-less-shops>
Zobraziť len 5 obchodov
{{#stopSpinner stopSpin=stopSpin}}
{{#if showSpinner}}
Spinner
{{/if}}
{{/stopSpinner}}
</button>
{{/if}}
Problem is that when I handle event, the spinner part is not shown till I delay list expanding.
So I expect DOM to be busy rendering.
But I dont like setTimeout and would like to use some better timing, is there any?
Or is there some better pattern ?
For now
Template.productAvailableShops.events
'click button[data-more-shops]': (event, instance) ->
instance.spinner.set(true)
Meteor.setTimeout(instance.incrementListLength, 100)