Component "didInsertElement" only get fired first time


#1

First off, thanks so much for all the help so far. Really got me off the ground and making some progress.

Ok, so I have a component to render a select list to which I pass a “selectedId” value. In the “didInsertElement” event I fire a function (with Ember.run.later) to initiallize the select2 plugin.

All works great, but I have a problem where I have a list of records (say mysite/things/) and when you click on one, I load a form to edit that item in the “outlet” (say mysite/things/2/edit). Works great except it seems when the form load for the second time (like when you select a new record) the component does not seem to get initialized again and the selected value stays the same.

I placed an alert in the “didInserrtElement” event and it only gets called the first time the edit templated are loaded.

Does hope that make sense? Not sure if I should bother you guys with a bunch of code rather?

PS: For what it matter, if I use that component several times on the same template (form) it works as expected.


#2

didInsertElement called once when inserted in DOM. So any change to that doesn’t trigger that hook. Maybe didReceiveAttrs hook is good for you.

Take a look at component lifecycle


#3