Skip to content

Commit

Permalink
Merge pull request #439 from dwabyick/gh-pages
Browse files Browse the repository at this point in the history
Changed window.app.* to app.* to match the example code in Example 1
  • Loading branch information
addyosmani committed May 25, 2013
2 parents de1fb4b + 496539e commit a070112
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions chapters/04-exercise-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -574,13 +574,13 @@ If you are following along, open `file://*path*/index.html` in your browser and

However, a few things can be tested through the JavaScript console.

In the console, add a new todo item: `window.app.Todos.create({ title: 'My first Todo item'});` and hit return.
In the console, add a new todo item: `app.Todos.create({ title: 'My first Todo item'});` and hit return.

![](img/todos_d.png)

If all is functioning properly, this should log the new todo we've just added to the todos collection. The newly created todo is also saved to Local Storage and will be available on page refresh.

`window.app.Todos.create()` executes a collection method (`Collection.create(attributes, [options])`) which instantiates a new model item of the type passed into the collection definition, in our case `app.Todo`:
`app.Todos.create()` executes a collection method (`Collection.create(attributes, [options])`) which instantiates a new model item of the type passed into the collection definition, in our case `app.Todo`:

```javascript

Expand All @@ -597,7 +597,7 @@ If all is functioning properly, this should log the new todo we've just added to
Run the following in the console to check it out:
```javascript
var secondTodo = window.app.Todos.create({ title: 'My second Todo item'});
var secondTodo = app.Todos.create({ title: 'My second Todo item'});
secondTodo instanceof app.Todo // returns true
```
Expand Down Expand Up @@ -780,9 +780,9 @@ When the route changes, the todo list will be filtered on a model level and the

```
Our router uses a *splat to set up a default route which passes the string after '#/' in the URL to `setFilter()` which sets `window.app.TodoFilter` to that string.
Our router uses a *splat to set up a default route which passes the string after '#/' in the URL to `setFilter()` which sets `app.TodoFilter` to that string.
As we can see in the line `window.app.Todos.trigger('filter')`, once the filter has been set, we simply trigger 'filter' on our Todos collection to toggle which items are visible and which are hidden. Recall that our AppView's `filterAll()` method is bound to the collection's filter event and that any event on the collection will cause the AppView to re-render.
As we can see in the line `app.Todos.trigger('filter')`, once the filter has been set, we simply trigger 'filter' on our Todos collection to toggle which items are visible and which are hidden. Recall that our AppView's `filterAll()` method is bound to the collection's filter event and that any event on the collection will cause the AppView to re-render.
Finally, we create an instance of our router and call `Backbone.history.start()` to route the initial URL during page load.
Expand Down

0 comments on commit a070112

Please sign in to comment.