JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://cloud.github.com/downloads/emberjs/ember.js/ember-0.9.5.min.js"></script>
<script type="text/x-handlebars">
<p>
With inline default bindings, the message is {{MyApp.obj1.theMessage}}.
</p>
<p>
With deferred default bindings, the message is {{MyApp.obj2.theMessage}}.
</p>
</script>
JavaScript
MyApp = Ember.Application.create();
MyApp.model = Ember.Object.create({
message: 'lolwut'
});
MyApp.classWithInlineDefaultBindings = Ember.Object.extend({
theMessageBinding: 'MyApp.model.message'
});
MyApp.classWithDeferredDefaultBindings = Ember.Object.extend({
// set this at creation time as needed in unit tests:
theMessage: null,
init: function() {
// otherwise we'll set the default binding here, but...
// I miss my Ember syntax sugar! :(
if(!this.get('theMessage')) Ember.bind(this, 'theMessage', 'MyAppModel.model.message');
}
});
MyApp.obj1 = MyApp.classWithInlineDefaultBindings.create({theMessage: 'something else'});
MyApp.obj2 = MyApp.classWithDeferredDefaultBindings.create({theMessage: 'something else'});