#notEmpty() and #notNull()
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: [],
notEmptyValueBinding: Ember.Binding.notEmpty('value', 'is empty'),
notNullValueBinding: Ember.Binding.from('value').notNull('is null'),
setSync: function(property, value) {
this.set(property, value);
Ember.run.sync(); // synchronize bindings
this.pushObject('value = %@ ; notEmptyValue = %@ ; notNullValue = %@'.fmt(this.get('value'), this.get('notEmptyValue'), this.get('notNullValue')));
}
});
App.obj.setSync('value', null);
App.obj.setSync('value', '');
App.obj.setSync('value', []);
App.obj.setSync('value', 1);
App.obj.setSync('value', [1, 2]);