You add all items on the startup right? Just try to add them with some delay, f.e. 5 seconds after template got rendered. I think uihooks works only when you add new items after the rendering process.
in the time onRendered is run, all these 3 items are most probably already rendered.
Just add/remove them with mongol to check if it behaves as you expect when adding.
@XTA, @shock - you are right, hooks work only on elements added after tpl was rendered.
But that’s most unfortunate… how can I delay rendering of initial elements in {{#each}} block?
Actually, I want to animate all .items. But I need to animate them on initial page load. And I have to call a custom animation function, that’s why I wanted to hook into the #each rendering process.
Is not enough that user have to wait till page loads, now you want him to wait even longer till some animation finish ?
I think animations are good to mask slow data, but not to extend unusability even more.
And you can create template level reactive var, which you will change in onRendered/
If you return in items helper null till that reactive var will be true, you can easily delay it that way.
Yes, I’ve attached a simple Session to the helper and now _uihooks function runs. But now it doesn’t render the .items themselves! only runs console.log
Note that when you set one of these functions on a container element, Blaze will not do the actual operation; it’s your responsibility to actually insert, move, or remove the node (by calling $(node).remove(), for example).
And what would you expect be the next DOM element inside container before which you want to insert it?
When you are adding 1st element, that null sounds quite reasonable.
I created a new meteor project, took the JS you have and replaced the JS in my new project with it completely. Did the same for the HTML and I get 3 console.logs.