title: Understanding Ember Views
body: <p>I'm looking for some clarification on views in Ember.js</p>
  
  <p>Coming from a rails background and I'm trying to ignore any preconceptions. From what I understand of the ember framework there are 5 components:</p>
  
  <ul>
  <li>Routes: This is where we define the state of the application. The state is reflected in the URL. We can also define data loading here. Route classes are defined and on startup ember creates route objects which last for the duration of the application.</li>
  <li>Models: This is where object data is defined. Can also define computed properties. A model object is created for each json object returned from the server.</li>
  <li>Controllers: This mediates interactions between the models and templates/views. Controller classes are defined and on startup ember creates controller objects which last for the duration of the application. There is only ever a single instance of each controller class.</li>
  <li>Templates: These describe the generated markup.</li>
  <li>Views: These are specific templates or dom elements relating to a model. These are used to define interface events and send them to the controller for handling. Not sure when to create these.</li>
  </ul>
  
  <p>As an example lets say I have a EventsController that has data loaded on the applicationRoute:</p>
  
  <pre><code>ScheduleApp.EventsController = Ember.ArrayController.extend();
  
  ScheduleApp.ApplicationRoute = Ember.Route.extend({
    setupController: function() {
      this.controllerFor('events').set('content', ScheduleApp.Event.find());
    }
  });
  </code></pre>
  
  <p>Now in my template instead of iterating over each and displaying the information I want to iterate over each and create an associated view so I can add interactions to each event. I presume I would need to create a new view for each event and have it display in my template. However, I'm not sure where I create these views. Do I define a view class and then ember will create a new view object each time I call it using the view helper? Eventually I would like to use the appendTo on the view to inject my events to different places in the dom. Where would this be defined?</p>
  
  <p>I've tried reading over the ember.js guide for views but it describes the context of a creating a single view. I think I want to make many views for each event and then dynamically interact with those objects.</p>
  
  <p>Up to now ember has been outrageously clever so I would assume there is a built in method for generating these views. After all, most user interfaces are full of lists that require interactions. The problem is the list I'm trying to make I then want to spread over the dom depending on its attributes.</p>