title: Detect route/view transition in Ember.js application
body: <p>The router of my application looks like this (it's CoffeeScript):</p>
  
  <pre><code>App.Router.map () -&gt;
    @resource 'conversations', { path: '/' } -&gt;
      @resource 'conversation', { path: ':conversation_id' }
      @route 'new'
  </code></pre>
  
  <p>So, in my app, I have paths like <code>/new</code>, <code>/1</code>, <code>/2</code>, etc.</p>
  
  <p>I would like to detect a transition from <code>/1</code> to <code>/2</code> to make some initializations in my view (basically, put the focus on a textarea field). Unfortunately, as <code>/1</code> and <code>/2</code> use the same route, it seems nearly impossible to detect that transition.</p>
  
  <p>I tried by using <code>didInsertElement</code> in the view (as described <a href="https://stackoverflow.com/questions/16929672/emberjs-didinsertelement-for-previously-displayed-view">here</a>) or by observing <code>currentPath</code> in the controller (as described <a href="https://stackoverflow.com/questions/14425276/detect-route-transitions-in-emberjs-1-0-0-pre-4">here</a>). It works fine if I go from <code>/new</code> to <code>/1</code> (different routes) but not if I go from <code>/1</code> to <code>/2</code>.</p>
  
  <p>I found <a href="https://gist.github.com/jamesarosen/1592144" rel="nofollow noreferrer">this gist</a> suggesting to use the <code>StateManager</code> but it seems outdated (and I'm not sure it's really what I need).</p>
  
  <p>What do you suggest me to do?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>It seems that <code>setupController</code> is called every time so I decided to overload it like this:</p>
  
  <pre><code>App.ConversationRoute = Ember.Route.extend {
  
    setupController: (controller, model) -&gt;
      controller.set 'model', model
      # do something here?
  
  }
  </code></pre>
  
  <p>And I want the <code>init</code> method in my view to be called:</p>
  
  <pre><code>App.ConversationView = Ember.View.extend {
  
    init: -&gt;
      @$('form textarea').focus()
  
  }
  </code></pre>
  
  <p>But I still can't figure out how to make these two things work together (it's a problem because I read that the controller is not supposed to know about the view).</p>
  
  <p>Thank you for your help!</p>