Commit 9ca024d4 authored by Aaron Boushley's avatar Aaron Boushley

Preventing the backbone.js example from unnecessarily polluting the global namespace.

parent 60185e13
...@@ -10,7 +10,7 @@ $(function(){ ...@@ -10,7 +10,7 @@ $(function(){
// ---------- // ----------
// Our basic **Todo** model has `content`, `order`, and `done` attributes. // Our basic **Todo** model has `content`, `order`, and `done` attributes.
window.Todo = Backbone.Model.extend({ var Todo = Backbone.Model.extend({
// Default attributes for the todo. // Default attributes for the todo.
defaults: { defaults: {
...@@ -43,7 +43,7 @@ $(function(){ ...@@ -43,7 +43,7 @@ $(function(){
// The collection of todos is backed by *localStorage* instead of a remote // The collection of todos is backed by *localStorage* instead of a remote
// server. // server.
window.TodoList = Backbone.Collection.extend({ var TodoList = Backbone.Collection.extend({
// Reference to this collection's model. // Reference to this collection's model.
model: Todo, model: Todo,
...@@ -76,13 +76,13 @@ $(function(){ ...@@ -76,13 +76,13 @@ $(function(){
}); });
// Create our global collection of **Todos**. // Create our global collection of **Todos**.
window.Todos = new TodoList; var Todos = new TodoList;
// Todo Item View // Todo Item View
// -------------- // --------------
// The DOM element for a todo item... // The DOM element for a todo item...
window.TodoView = Backbone.View.extend({ var TodoView = Backbone.View.extend({
//... is a list tag. //... is a list tag.
tagName: "li", tagName: "li",
...@@ -162,7 +162,7 @@ $(function(){ ...@@ -162,7 +162,7 @@ $(function(){
// --------------- // ---------------
// Our overall **AppView** is the top-level piece of UI. // Our overall **AppView** is the top-level piece of UI.
window.AppView = Backbone.View.extend({ var AppView = Backbone.View.extend({
// Instead of generating a new element, bind to the existing skeleton of // Instead of generating a new element, bind to the existing skeleton of
// the App already present in the HTML. // the App already present in the HTML.
...@@ -254,6 +254,6 @@ $(function(){ ...@@ -254,6 +254,6 @@ $(function(){
}); });
// Finally, we kick things off by creating the **App**. // Finally, we kick things off by creating the **App**.
window.App = new AppView; var App = new AppView;
}); });
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