Commit 3b725068 authored by Aaron Boushley's avatar Aaron Boushley

Got the binding for the clear completed visibility figured out using a global binding.

parent 2326f6bc
...@@ -50,8 +50,8 @@ ...@@ -50,8 +50,8 @@
{{/view}} {{/view}}
<!-- Insert this after the CreateTodoView and before the collection. --> <!-- Insert this after the CreateTodoView and before the collection. -->
{{#view Todos.StatsView id="todo-stats"}} {{#view Todos.StatsView id="todo-stats" content=this}}
{{#view Ember.Button target="Todos.todosController" action="clearCompletedTodos" content=this}} {{#view Ember.Button target="Todos.todosController" action="clearCompletedTodos" classNameBindings="Todos.todosController.completeClass" content=this}}
Clear {{content.completedString}} Clear {{content.completedString}}
{{/view}} {{/view}}
{{remainingString}} left {{remainingString}} left
......
...@@ -52,6 +52,10 @@ Todos.todosController = Ember.ArrayProxy.create({ ...@@ -52,6 +52,10 @@ Todos.todosController = Ember.ArrayProxy.create({
} else { } else {
return !!this.get('length') && this.everyProperty('isDone', true); return !!this.get('length') && this.everyProperty('isDone', true);
} }
}.property('@each.isDone'),
completeClass: function () {
return this.get('completed') < 1 ? 'none-completed' : 'some-completed';
}.property('@each.isDone') }.property('@each.isDone')
}); });
...@@ -66,10 +70,7 @@ Todos.StatsView = Ember.View.extend({ ...@@ -66,10 +70,7 @@ Todos.StatsView = Ember.View.extend({
completedString: function() { completedString: function() {
var completed = this.get('completed'); var completed = this.get('completed');
return completed + " completed" + (completed === 1 ? " item" : " items"); return completed + " completed" + (completed === 1 ? " item" : " items");
}.property('completed'), }.property('completed')
updateCompletedButton: function () {
$('#todo-stats button').toggleClass('none-completed', this.get('completed') < 1);
}.observes('completed')
}); });
Todos.CreateTodoView = Ember.TextField.extend({ Todos.CreateTodoView = Ember.TextField.extend({
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment