#bool(), #not() & #isNull()
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: [],
boolValueBinding: Ember.Binding.bool('value'),
notValueBinding: Ember.Binding.not('value'),
isNullValueBinding: Ember.Binding.from('value').isNull(),
setSync: function(property, value){
this.set(property, value);
Ember.run.sync(); // synchronize bindings
this.pushObject( 'value = %@ ; boolValue = %@ ; notValue = %@ ; isNullValue = %@'.fmt( this.get('value'), this.get('boolValue'), this.get('notValue'), this.get('isNullValue')) );
}
});
App.obj.setSync('value', null);
App.obj.setSync('value', false);
App.obj.setSync('value', []);
App.obj.setSync('value', '');
App.obj.setSync('value', 'hello');
App.obj.setSync('value', [1]);
App.obj.setSync('value', {});