Singleton Controller - Rerun Initialization Code

Hi, I have an edit controller with a few fields and a tags input. Essentially, when I load the route I initialize my variables and after

{{input type="text" class="form-control" id="crTags" value=crTags placeholder="Enter tags"}}

I have {{initDash}} with initDash: Ember.computed(function(){ $('#crTags').tagsInput(); }), to initialize the tags input.

The problem is when I navigate away from the page and return back, the initDash is not called, therefore the tagsInput does not run. From what I understand Ember controllers are singletons and therefore do not refresh entirely if the app returns to it. I was wondering how I can call $('#crTags').tagsInput(); after the html has been inserted regardless of whether or not this is the first or multiple time visiting the page.

Computed properties are cached. You can use Object#notifyPropertyChange to invalidate that cache. Furthermore, Route#resetController hook can be used to reset the controller every time you navigate away from the route.

Since changing controller means changing the template, so I’m guessing that your input will be re-rendered every time you enter / leave this route. If it’s the case, I think you can use didInsertElement() hook to do the magic.