title: Using ember-data to perform a UI update with user defined parameters
body: <p>I am currently working on an ember.js app, using ember-data with its RESTAdapter to communicate with my service.</p>
  
  <p>I defined the needed ember-data models and everything seems to work fine, but I am not quite sure, if I am going in the right direction - so this is going to be a "Is that solution alright?"-question.</p>
  
  <p>Our service API provides a method to get records limited to a requested time frame - the REST request parameters simply look like this:</p>
  
  <pre><code>{ from: ..., to: ... }
  </code></pre>
  
  <p>The user of my UI should be able to select a time frame and the UI should update with the data within the requested time frame.</p>
  
  <p>There will be no write operations for now - this is a read-only UI.</p>
  
  <p><strong>Here is my current solution:</strong></p>
  
  <p>I defined a route class which provides the model for the request result and an ArrayController which serves the UI.</p>
  
  <p>Route Class Code:</p>
  
  <pre><code>MyModelRoute = Ember.Route.extend
      model: -&gt;
          # Calling controller to get the required parameters for the initial
          # model setup - this doesn't feel right too, but I want to keep the
          # time frame parameters for the JSON request at one position (controller)...
          controller = @controllerFor('my_models')
          # get fromDate and toDate from controller
          MyModel.find({from: fromDate, to: toDate})
  </code></pre>
  
  <p>ArrayController Code:</p>
  
  <pre><code>MyModelController = Ember.ArrayController.extend
      updateMyModels: -&gt; 
          # ... some boring code to get fromDate and toDate ...
  
          # Overwriting the content property which was previously set by
          # route's model property seems to be nasty...
          myModels = MyModel.find({from: fromDate, to: toDate})
          myModels.one('didLoad', =&gt;
              @set('content', myModels) 
          )
  </code></pre>
  
  <p>My view provides two date pickers, allowing the user to specify which time frame she wants to see (<code>fromDate</code> and <code>toDate</code> in my sample code).</p>
  
  <p>Whenever the user selects a new time frame, two observed variables on my controller are updated which will cause a new request to the server with the user requested time frame (<code>updateMyModels()</code> method in my sample).</p>
  
  <p><strong>So, here is my point:</strong> As you can see, I am currently updating the 'content' property of my ArrayController within the controller's <code>updateMyModels()</code> method which is bound to the UI timeframe properties - I am totally ignoring the previously provided route's model. So the model property on my route just exists to "initialize" my controller which seems to be a bit odd...</p>
  
  <p>Everything works fine, but I am wondering if there is a better / right way to do that?</p>
  
  <p>If I should use the model provided by the route instead of a controller property:
  Is there a way to communicate with the route's model from the controller (I am sure there is a way ;-) ), and more important: how can I reload the current route from my controller? Is the <code>transitionTo()</code> method the right way?</p>
  
  <p>Thanks in advance!</p>