Ember latest Template
by ppanagi
HTML
<script src="https://github.com/downloads/wycats/handlebars.js/handlebars-1.0.0.beta.6.js"></script>
<script src="https://github.com/downloads/emberjs/ember.js/ember-latest.min.js"></script>
<script type="text/x-handlebars">
</script>
CSS
body {
padding: 2em;
}
div{
margin: 5px 0;
}
JavaScript
// MyApp namespace
window.App = Ember.Application.create();
// Create and append container
App.container = Ember.ContainerView.create({
sss: function(){
}.observes('childView'
});
App.container.append();
// Grab child views array
var childViews = App.container.get('childViews');
App.Label = Ember.View.extend({
label: null,
template: Ember.Handlebars.compile('<div>{{view.label}}</div>')
})
// Add custom view
childViews.pushObject(App.Label.create({label:'Label1'}));
childViews.pushObject(App.Label.create({label:'Label2'}));
childViews.pushObject(App.Label.create({label:'Label3'}));
childViews.pushObject(App.Label.create({label:'Label4'}));
setTimeout(function(){
console.log(App.container.get('childViews'));
App.container.set('childViews', childViews.reverse());
console.log(App.container.get('childViews'));
}, 3000);