Ember.js 0.9.3 template

by reubenposthuma

HTML

<script src="http://cloud.github.com/downloads/wycats/handlebars.js/handlebars-1.0.rc.1.js"></script>
<script src="http://cloud.github.com/downloads/emberjs/ember.js/ember-1.0.0-pre.2.min.js"></script>
    <div class='span12' id='surveyContainer'>
</div>
      <script data-template-name="app" type="text/x-handlebars">
      {{outlet}}
      <div {{action incrementStep}} class='btn'>Next ></div>
      </script>
      <script data-template-name="Test Content Type" type="text/x-handlebars">
      <div class = "survey_box">
      {{data.question}}
      {{view Ember.TextField valueBinding="answer"}}
      </div>
      </script>
      <script data-template-name="Facebook" type="text/x-handlebars">
      {{#if App.FBUser}}
      Thanks, you're connected with facebook!
      {{else}}
      {{#view Em.FacebookView type="login-button" data-size="xlarge" data-scope="email, offline_access"}}
      Connect with facebook
      {{/view}}
      {{/if}}
      </script>
      <script data-template-name="final" type="text/x-handlebars">
      DONE BRO!
      </script>

JavaScript

var survey_contents = [{"content_type_id":3,"created_at":"2012-12-12T15:54:34Z","data":"[]","id":3,"position":1,"survey_id":1,"updated_at":"2012-12-12T17:11:32Z"},{"content_type_id":2,"created_at":"2012-12-06T07:26:09Z","data":"[\"Name \"]","id":1,"position":2,"survey_id":1,"updated_at":"2012-12-12T17:11:57Z"},{"content_type_id":2,"created_at":"2012-12-07T05:01:04Z","data":"[\"What is your campus?\"]","id":2,"position":3,"survey_id":1,"updated_at":"2012-12-12T17:21:23Z"}];
        var content_types = [{"id":3,"js":"parse = {\r\n  data: function(data) {\r\n    return {question: data[0]};\r\n  },\r\n  \r\n  render: function() {\r\n  },\r\n  \r\n  enter: function(_read, _write, currentID, data, context) {\r\n    context._propertySet('answer', _read(currentID));\r\n  },\r\n  \r\n  exit: function(_read, _write, currentID, data, context) {\r\n    _write( currentID, App.FBUser.name );\r\n    _write( data.namePos, App.FBUser.name );\r\n    _write( 2, App.FBUser.hometown.name );\r\n  }\r\n};","name":"Facebook"},{"id":2,"js":"parse = {\r\n  data: function(data) {\r\n    return {question: data[0]};\r\n  },\r\n  \r\n  render: function() {\r\n  },\r\n  \r\n  enter: function(_read, _write, currentID, data, context) {\r\n    context._propertySet('answer', _read(currentID));\r\n  },\r\n  \r\n  exit: function(_read, _write, currentID, data, context) {\r\n    _write( currentID, context.answer );\r\n  }\r\n};","name":"Test Content Type"}]

nextStep = 1;

subViews = new Array();
content_types_obj = Ember.ArrayProxy.create({content: content_types});

App = Ember.Application.create({
    rootElement: '#surveyContainer',
    nextStep: 1,
    appId: 113411778806173
});

App.SurveyData = Ember.ArrayProxy.create({
  content: [],

  uploadData: function() {
    $.post('upload', JSON.stringify(this.content,null));
  }
});


App.surveyViews = [];
App.surveyControllers = [];

for(i = 0; i<survey_contents.length; i++) {
  content_type_id = survey_contents[i].content_type_id;
  content_type =...