Ember & Data Latest
The latest build of Ember.
HTML
<script src="http://ember.alexspeller.com/handlebars-1.0.0.js"></script>
<script src="http://ember.alexspeller.com/ember-latest.js"></script>
<script src="http://ember.alexspeller.com/ember-data-latest.js"></script>
<script type="text/x-handlebars" data-template-name="application">
<h1>{{title}}</h1>
<p>Comment count: {{comments.length}}</p>
{{#each comments}}
<p>{{body}}</p>
{{/each}}
</script>
CSS
h1 { font-size: 1.6em; padding-bottom: 10px; }
h2 { font-size: 1.4em; }
ul { padding: 15px; font-size: 1.4em; color: green; }
.url {
font-family: sans-serif;
padding: 0.5em;
border: 1px solid black;
}
CoffeeScript
window.App = Ember.Application.create()
App.Store = DS.Store.extend
adapter: DS.FixtureAdapter
App.Post = DS.Model.extend
title: DS.attr('string')
comments: DS.hasMany('comment', async: true)
App.Comment = DS.Model.extend
body: DS.attr('string')
App.ApplicationRoute = Em.Route.extend
model: -> @store.find('post', 1)
App.Post.FIXTURES = [
id: 1
title: "Test post"
]
App.Comment.FIXTURES = [
id: 1
post_id: 1
body: "Test comment"
]