I have an Ember app in which there's an Index view and on the same page (nested) there's a corresponding detail view. Let's say the resource we're dealing with is a Post - and a Post can have many Comments. On the index page there's a list of Posts - each one is clickable. When you click on a Post - the detail portion of the page loads with the Post's details - including a semantic-ui accordion for the Comments.
I've subclassed Ember.Component in order to create a semantic-accordion component and display an accordion with a Post's comments. In semantic-accordion's 'didInsertElement' method - I found it necessary to do the following in order to get the accordion to work ...
didInsertElement: ->
@_super()
Ember.run.scheduleOnce 'afterRender', this, ->
@$().accordion()
This works great - except, and here's the rub - it only works after a page reload. If I click on a different Post - in order to view the details of that Post - the accordion for the newly clicked Post's comments does not work. I know why it doesn't work - because the 'didInsertElement' method didn't execute again as a result of the ajax-based 'detail' reload. I'm just not sure what to do to fix it. Hoping someone here knows.
Thanks