Ember JS pushObject Test 1
Using Ember 0.9.6, the template is correctly populated from the content array in the songsController ArrayController.
by BrownieBoy
HTML
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>EmberJS pushObject Test</title>
</head>
<body>
<script type="text/x-handlebars">
{{#each Songs.songsController}}
<h3>{{title}}</h3>
<p>{{artist}} - {{genre}}</p>
{{/each}}
</script>
<script src="http://cloud.github.com/downloads/emberjs/ember.js/ember-0.9.6.min.js"></script>
</body>
</html>
JavaScript
Songs = Ember.Application.create();
Songs.Song = Ember.Object.extend({
title: null,
artist: null,
genre: null,
listens: 0
});
Songs.songsController = Ember.ArrayController.create({
content: [],
init: function() {
// create an instance of the Song model
var song = Songs.Song.create({
title: 'Son of the Morning',
artist: 'Oh, Sleeper',
genre: 'Screamo'
});
this.pushObject(song);
song = Songs.Song.create({
title: '1969',
artist: 'The Stooges',
genre: 'Punk'
});
this.pushObject(song);
}
});
console.log("Songs.songsController content = " + JSON.stringify(Songs.songsController.get('content')));