emberjs/website — pull request #1056 by mikepmunroe (2013-11-07 22:27:40+00:00)
Title: add more additional line comments to display-a-button-to-remove-completed-todos code sample

I could envision a noob user getting confused and replacing code within actions instead of appending code to actions within the code example I supplied a change for.

Below, I output the todos_controller.js before and after the code change demonstrated by the code sample I added extra 'additional lines' comments to

controller before code example change:
````javascript
Todos.TodosController = Ember.ArrayController.extend({
actions: {
createTodo: function () {
// Get the todo title set by the "New Todo" text field
var title = this.get('newTitle');
if (!title.trim()) { return; }

// Create the new Todo model
var todo = this.store.createRecord('todo', {
title: title,
isCompleted: false
});

// Clear the "New Todo" text field
this.set('newTitle', '');

// Save the new model
todo.save();
}
},

remaining: function () {
return this.filterProperty('isCompleted', false).get('length');
}.property('@each.isCompleted'),

inflection: function () {
var remaining = this.get('remaining');
return remaining === 1 ? 'item' : 'items';
}.property('remaining')
});
````
controller following code example change:
````javascript
Todos.TodosController = Ember.ArrayController.extend({
actions: {
createTodo: function () {
// Get the todo title set by the "New Todo" text field
var title = this.get('newTitle');
if (!title.trim()) { return; }

// Create the new Todo model
var todo = this.store.createRecord('todo', {
title: title,
isCompleted: false
});

// Clear the "New Todo" text field
this.set('newTitle', '');

// Save the new model
todo.save();
},
clearCompleted: function () {
var completed = this.filterProperty('isCompleted', true);
completed.invoke('deleteRecord');
completed.invoke('save');
}
},

remaining: function () {
return this.filterProperty('isCompleted', false).get('length');
}.property('@each.isCompleted'),

inflection: function () {
var remaining = this.get('remaining');
return remaining === 1 ? 'item' : 'items';
}.property('remaining'),

hasCompleted: function () {
return this.get('completed') > 0;
}.property('completed'),

completed: function () {
return this.filterProperty('isCompleted', true).get('length');
}.property('@each.isCompleted')
});
````