Simple starting point for Ember.js fiddles
HTML
<script src="https://github.com/downloads/emberjs/ember.js/ember-0.9.5.js"></script>
<script type="text/x-handlebars" >
{{#view App.MainView}}
{{view App.MyContainerView elementId="my_container_view"}}
<h1>Hello world!</h1>
<br>
{{view App.AddChildViewButton}}
<br>
{{/view}}
</script>
JavaScript
App = Ember.Application.create({});
App.MainView = Em.View.extend({
classNames: ['mainView']
});
App.MyContainerView = Em.ContainerView.extend({});
App.AnotherView = Em.View.extend({
render: function(buffer){
buffer.push('App.AnotherView ' + this.get('elementId'));
}
});
App.AddChildViewButton = Em.View.extend({
tagName: 'button',
render: function(buffer) {
buffer.push('Add Child View');
},
click: function() {
var containerView = Em.View.views['my_container_view']
var childView = containerView.createChildView(App.AnotherView);
containerView.get('childViews').pushObject(childView);
}
});