Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
todomvc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eugene Shen
todomvc
Commits
9ca024d4
Commit
9ca024d4
authored
Dec 29, 2011
by
Aaron Boushley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Preventing the backbone.js example from unnecessarily polluting the global namespace.
parent
60185e13
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
todo-example/backbone/js/todos.js
todo-example/backbone/js/todos.js
+6
-6
No files found.
todo-example/backbone/js/todos.js
View file @
9ca024d4
...
@@ -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
;
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment