I am trying out ember.js and I am struggling with rendering an array of items to the template:
index.html
<script type="text/x-handlebars">
{{App.test}}
</script>
<script type="text/x-handlebars">
{{#each App.eventsController}}
<p>{{title}}</p>
{{/each}}
</script>
<!-- le javascript -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.2.min.js"><\/script>')</script>
<script src="js/libs/handlebars-1.0.0.beta.6.js"></script>
<script src="js/libs/ember-1.0.pre.min.js"></script>
<script src="js/app.js"></script>
</body>
app.js
var App = Em.Application.create({
test : 'does it work?...'
});
App.Event = Ember.Object.extend({
title: '',
body: ''
});
App.eventsController = Ember.ArrayController.create({
events: [],
init: function() {
self = this;
self.pushObject(App.Event.create({
title: "Event 1",
body: "Content"
}));
}
});
The first binding (App.test) does work fine. Only my second call does nothing but putting an empty handlebar-script-tag into my DOM.
So what am I missing here?