I would recommend wrapping your items in their own look. In this case, you can use the didInsertElement hook to trigger your logic.
So your rudders look like this:
{{#each item in controller}} {{view App.ItemView contextBinding="item"}} {{/each}}
Just move the current contents of your loop to this new template. The view will look something like this:
App.ItemView = Em.View.extend templateName: 'item' didInsertElement: ( -> Ember.run.next this, -> @.$().collapse() )
I think that would be the most awesome approach. This seems better because the logic does not restart every time the contents of the controller are swapped. As you already said, the didInsertElement hook is the most suitable place for integration with third-party libraries.
Hint: This did not work when you put the logic in the didInsertElement hook of your IndexView, because at that time the contained collection was not yet displayed.
source share