Ember.Binding#single()
by pangratz666
HTML
<script src="https://github.com/downloads/pangratz/ember.js/ember.js"></script>
<script type="text/x-handlebars" >
{{#each App.obj}}
<p>{{this}}</p>
{{/each}}
</script>
JavaScript
App = Ember.Application.create();
App.obj = Ember.ArrayProxy.create({
content: [],
boundValueBinding: Ember.Binding.single('value', 'more entries available'),
setSync: function(property, value){
this.set(property, value);
Ember.run.sync(); // synchronize bindings
this.pushObject( 'value: %@ ; boundValue: %@'.fmt( this.get('value'), this.get('boundValue')) );
}
});
App.obj.setSync('value', null);
App.obj.setSync('value', 1);
App.obj.setSync('value', [1,2]);
App.obj.setSync('value', [3]);