5. var Animal, myAnimal;
Animal = function (name) {
this.name = name || 'Unknown';
}
Animal.prototype = {
say: function () {
console.log(
'Hi, my name is ' + this.name + '!'
);
}
}
myAnimal = new Animal('Bello');
myAnimal.say(); // Hi, my name is Bello!
6. var Animal, myAnimal;
Animal = function (name) {
this.name = name || 'Unknown';
}
Animal.prototype = {
say: function () {
console.log(
'Hi, my name is ' + this.name + '!'
);
}
}
myAnimal = new Animal('Bello');
myAnimal.say(); // Hi, my name is Bello!
7. var Animal, myAnimal;
Animal = function (name) {
this.name = name || 'Unknown';
}
Animal.prototype = {
say: function () {
console.log(
'Hi, my name is ' + this.name + '!'
);
}
}
myAnimal = new Animal('Bello');
myAnimal.say(); // Hi, my name is Bello!
8. var Animal, myAnimal;
Animal = function (name) {
this.name = name || 'Unknown';
}
Animal.prototype = {
say: function () {
console.log(
'Hi, my name is ' + this.name + '!'
);
}
}
myAnimal = new Animal('Bello');
myAnimal.say(); // Hi, my name is Bello!
9. var Animal, myAnimal;
Animal = function (name) {
this.name = name || 'Unknown';
}
Animal.prototype = {
say: function () {
console.log(
'Hi, my name is ' + this.name + '!'
);
}
}
myAnimal = new Animal('Bello');
myAnimal.say(); // Hi, my name is Bello!
10. var Animal, myAnimal;
Animal = function (name) {
this.name = name || 'Unknown';
}
Animal.prototype = {
say: function () {
console.log(
'Hi, my name is ' + this.name + '!'
);
}
}
myAnimal = new Animal('Bello');
myAnimal.say(); // Hi, my name is Bello!
11. var Animal, myAnimal;
Animal = function (name) {
this.name = name || 'Unknown';
}
Animal.prototype = {
say: function () {
console.log(
'Hi, my name is ' + this.name + '!'
);
}
}
myAnimal = new Animal('Bello');
myAnimal.say(); // Hi, my name is Bello!
12. var Animal, myAnimal;
Animal = function (name) {
this.name = name || 'Unknown';
}
Animal.prototype = {
say: function () {
console.log(
'Hi, my name is ' + this.name + '!'
);
}
}
myAnimal = new Animal('Bello');
myAnimal.say(); // Hi, my name is Bello!
15. var Animal = Backbone.Model.extend({
say: function () {}
});
var Dog = Animal.extend({
bark: function () {}
});
16. var Animal = Backbone.Model.extend({
say: function () {}
});
var Dog = Animal.extend({
bark: function () {}
});
17. var Animal = Backbone.Model.extend({
say: function () {}
});
var Dog = Animal.extend({
bark: function () {}
});
18. var Animal = Backbone.Model.extend({
say: function () {}
});
var Dog = Animal.extend({
bark: function () {}
});
19. var Animal = Backbone.Model.extend({
say: function () {}
});
var Dog = Animal.extend({
bark: function () {}
});
20. var Animal = Backbone.Model.extend({
say: function () {}
});
var Dog = Animal.extend({
bark: function () {}
});
21. var Dog = Animal.extend({
bark: function () {}
});
var myDog = new Dog({
name: 'Bello'
});
22. var Dog = Animal.extend({
bark: function () {}
});
var myDog = new Dog({
name: 'Bello'
});
23. // The self-propagating extend function that Backbone classes use.
var extend = function (protoProps, classProps) {
var child = inherits(this, protoProps, classProps);
child.extend = this.extend;
return child;
};
// Set up inheritance for the model, collection, and view.
Backbone.Model.extend = Backbone.Collection.extend =
Backbone.Router.extend = Backbone.View.extend = extend;
24. // The self-propagating extend function that Backbone classes use.
var extend = function (protoProps, classProps) {
var child = inherits(this, protoProps, classProps);
child.extend = this.extend;
return child;
};
// Set up inheritance for the model, collection, and view.
Backbone.Model.extend = Backbone.Collection.extend =
Backbone.Router.extend = Backbone.View.extend = extend;
25. // The self-propagating extend function that Backbone classes use.
var extend = function (protoProps, classProps) {
var child = inherits(this, protoProps, classProps);
child.extend = this.extend;
return child;
};
// Set up inheritance for the model, collection, and view.
Backbone.Model.extend = Backbone.Collection.extend =
Backbone.Router.extend = Backbone.View.extend = extend;
26. // The self-propagating extend function that Backbone classes use.
var extend = function (protoProps, classProps) {
var child = inherits(this, protoProps, classProps);
child.extend = this.extend;
return child;
};
// Set up inheritance for the model, collection, and view.
Backbone.Model.extend = Backbone.Collection.extend =
Backbone.Router.extend = Backbone.View.extend = extend;
27. // The self-propagating extend function that Backbone classes use.
var extend = function (protoProps, classProps) {
var child = inherits(this, protoProps, classProps);
child.extend = this.extend;
return child;
};
// Set up inheritance for the model, collection, and view.
Backbone.Model.extend = Backbone.Collection.extend =
Backbone.Router.extend = Backbone.View.extend = extend;
32. var AppRouter = Backbone.Router.extend({
routes: {
'': 'index',
'q?:query': 'query',
'show/:id': 'show'
},
index: function () {},
query: function (queryString) {},
show: function (id) {}
});
33. var AppRouter = Backbone.Router.extend({
routes: {
'': 'index',
'q?:query': 'query',
'show/:id': 'show'
},
index: function () {},
query: function (queryString) {},
show: function (id) {}
});
34. var AppRouter = Backbone.Router.extend({
routes: {
'': 'index',
'q?:query': 'query',
'show/:id': 'show'
},
index: function () {},
query: function (queryString) {},
show: function (id) {}
});
35. var AppRouter = Backbone.Router.extend({
routes: {
'': 'index',
'q?:query': 'query',
'show/:id': 'show'
},
index: function () {},
query: function (queryString) {},
show: function (id) {}
});
36. var AppRouter = Backbone.Router.extend({
routes: {
'': 'index',
'q?:query': 'query',
'show/:id': 'show'
},
index: function () {},
query: function (queryString) {},
show: function (id) {}
});
37. var AppRouter = Backbone.Router.extend({
routes: {
'': 'index',
'q?:query': 'query',
'show/:id': 'show'
},
index: function () {},
query: function (queryString) {},
show: function (id) {}
});
38. var AppRouter = Backbone.Router.extend({
routes: {
'': 'index',
'q?:query': 'query',
'show/:id': 'show'
},
index: function () {},
query: function (queryString) {},
show: function (id) {}
});
39. var AppRouter = Backbone.Router.extend({
routes: {
'': 'index',
'q?:query': 'query',
'show/:id': 'show'
},
index: function () {},
query: function (queryString) {},
show: function (id) {}
});
40. var AppRouter = Backbone.Router.extend({
routes: {
'': 'index',
'q?:query': 'query',
'show/:id': 'show'
},
index: function () {},
query: function (queryString) {},
show: function (id) {}
});
41. var AppRouter = Backbone.Router.extend({
routes: {
'': 'index',
'q?:query': 'query',
'show/:id': 'show'
},
index: function () {},
query: function (queryString) {},
show: function (id) {}
});
44. var AppRouter = Backbone.Router.extend({
// …
});
new AppRouter();
Backbone.history.start();
45. var AppRouter = Backbone.Router.extend({
// …
});
new AppRouter();
Backbone.history.start();
46. var AppRouter = Backbone.Router.extend({
// …
});
new AppRouter();
Backbone.history.start();
50. var Comment = Backbone.Model.extend({});
var newComment = new Comment({
name: 'Pierre Spring',
email: 'pierre@nelm.io',
text: 'Hello World'
});
51. var Comment = Backbone.Model.extend({});
var newComment = new Comment({
name: 'Pierre Spring',
email: 'pierre@nelm.io',
text: 'Hello World'
});
52. var Comment = Backbone.Model.extend({});
var newComment = new Comment({
name: 'Pierre Spring',
email: 'pierre@nelm.io',
text: 'Hello World'
});
53. var Comment = Backbone.Model.extend({});
var newComment = new Comment({
name: 'Pierre Spring',
email: 'pierre@nelm.io',
text: 'Hello World'
});
54. var Comment = Backbone.Model.extend({});
var newComment = new Comment({
name: 'Pierre Spring',
email: 'pierre@nelm.io',
text: 'Hello World'
});
55. var Comment = Backbone.Model.extend({});
var newComment = new Comment({
name: 'Pierre Spring',
email: 'pierre@nelm.io',
text: 'Hello World'
});
56. var newComment = new Comment({
text: 'Hello World'
});
newComment.set({
name: 'Pierre Spring',
email: 'pierre.spring@caillou.ch'
});
newComment.get('name'); // Pierre Spring
57. var newComment = new Comment({
text: 'Hello World'
});
newComment.set({
name: 'Pierre Spring',
email: 'pierre.spring@caillou.ch'
});
newComment.get('name'); // Pierre Spring
58. var newComment = new Comment({
text: 'Hello World'
});
newComment.set({
name: 'Pierre Spring',
email: 'pierre.spring@caillou.ch'
});
newComment.get('name'); // Pierre Spring
59. var newComment = new Comment({
text: 'Hello World'
});
newComment.set({
name: 'Pierre Spring',
email: 'pierre.spring@caillou.ch'
});
newComment.get('name'); // Pierre Spring
60. var Comment = Backbone.Model.extend({});
var newComment = new Comment({ /* … */ });
newComment.save();
61. var Comment = Backbone.Model.extend({
url: '/api/comment/'
});
var newComment = new Comment({ /* … */ });
newComment.save();
63. var Comment = Backbone.Model.extend({
localStorage: new Store("comment")
});
var newComment = new Comment({ /* … */ });
newComment.save();
64. var Comment = Backbone.Model.extend({
localStorage: new Store("comment"),
initialize: function (options) {
}
});
var newComment = new Comment({ /* … */ });
newComment.save();
65. var Comment = Backbone.Model.extend({
localStorage: new Store("comment"),
initialize: function (options) {
if (!options.date) {
this.set({
date: moment().toString()
});
}
}
});
var newComment = new Comment({ /* … */ });
newComment.save();
66. var Comment = Backbone.Model.extend({
localStorage: new Store("comment"),
initialize: function (options) {
if (!options.date) {
this.set({
date: moment().toString()
});
}
}
});
var newComment = new Comment({ /* … */ });
newComment.save();
68. var Comment = Backbone.Model.extend({
localStorage: new Store("comment"),
initialize: function (options) {
if (!options.date) {
this.set({
date: moment().toString()
});
}
}
});
var newComment = new Comment({ /* … */ });
newComment.save();
69. var Comment = Backbone.Model.extend({
localStorage: new Store("comment"),
initialize: function (options) {
if (!options.date) {
this.set({
date: moment().toString()
});
}
},
getDisplayDate: function () {
var d = this.get('date');
return moment(d).fromNow();
}
});
70. var Comment = Backbone.Model.extend({
localStorage: new Store("comment"),
initialize: function (options) {
if (!options.date) {
this.set({
date: moment().toString()
});
}
},
getDisplayDate: function () {
var d = this.get('date');
return moment(d).fromNow();
}
});
71. var Comment = Backbone.Model.extend({
localStorage: new Store("comment"),
initialize: function (options) {
if (!options.date) {
this.set({
date: moment().toString()
});
}
},
getDisplayDate: function () {
var d = this.get('date');
return moment(d).fromNow();
}
});
72. var Comment = Backbone.Model.extend({
localStorage: new Store("comment"),
initialize: function (options) {
if (!options.date) {
this.set({
date: moment().toString()
});
}
},
getDisplayDate: function () {
var d = this.get('date');
return moment(d).fromNow();
}
});
73. var newComment = new Comment({ /* … */ });
newComment.getDisplayDate();
// a few seconds ago
136. var commentCollection = new commentCollection();
var commentView = new CommentView({
commentCollection: commentCollection
});
$('.list-view').html(commentView.el);
commentCollection.fetch();
137. var commentCollection = new commentCollection();
var commentView = new CommentView({
commentCollection: commentCollection
});
$('.list-view').html(commentView.el);
commentCollection.fetch();
138. var commentCollection = new commentCollection();
var commentView = new CommentView({
commentCollection: commentCollection
});
$('.list-view').html(commentView.el);
commentCollection.fetch();
139. var commentCollection = new commentCollection();
var commentView = new CommentView({
commentCollection: commentCollection
});
$('.list-view').html(commentView.el);
commentCollection.fetch();
140. var CommentFormView = Backbone.View.extend({
events: {
'submit form': 'newComment'
},
initialize: function (options) { /* … */ },
render: function () { /* … */ },
newComment: function (e) {
var options, comment;
e.preventDefault();
options = {};
_.each(
this.$('form').serializeArray(),
function (field) {
options[field.name] = field.value;
}
);
this.commentCollection.create(options);
this.$('input, textarea').val('');
}
});
141. var CommentFormView = Backbone.View.extend({
events: {
'submit form': 'newComment'
},
initialize: function (options) { /* … */ },
render: function () { /* … */ },
newComment: function (e) {
var options, comment;
e.preventDefault();
options = {};
_.each(
this.$('form').serializeArray(),
function (field) {
options[field.name] = field.value;
}
);
this.commentCollection.create(options);
this.$('input, textarea').val('');
}
});
142. var CommentFormView = Backbone.View.extend({
events: {
'submit form': 'newComment'
},
initialize: function (options) { /* … */ },
render: function () { /* … */ },
newComment: function (e) {
var options, comment;
e.preventDefault();
options = {};
_.each(
this.$('form').serializeArray(),
function (field) {
options[field.name] = field.value;
}
);
this.commentCollection.create(options);
this.$('input, textarea').val('');
}
});
143. var CommentFormView = Backbone.View.extend({
events: {
'submit form': 'newComment'
},
initialize: function (options) { /* … */ },
render: function () { /* … */ },
newComment: function (e) {
var options, comment;
e.preventDefault();
options = {};
_.each(
this.$('form').serializeArray(),
function (field) {
options[field.name] = field.value;
}
);
this.commentCollection.create(options);
this.$('input, textarea').val('');
}
});
144. var CommentFormView = Backbone.View.extend({
events: {
'submit form': 'newComment'
},
initialize: function (options) { /* … */ },
render: function () { /* … */ },
newComment: function (e) {
var options, comment;
e.preventDefault();
options = {};
_.each(
this.$('form').serializeArray(),
function (field) {
options[field.name] = field.value;
}
);
this.commentCollection.create(options);
this.$('input, textarea').val('');
}
});
145. var CommentFormView = Backbone.View.extend({
events: {
'submit form': 'newComment'
},
initialize: function (options) { /* … */ },
render: function () { /* … */ },
newComment: function (e) {
var options, comment;
e.preventDefault();
options = {};
_.each(
this.$('form').serializeArray(),
function (field) {
options[field.name] = field.value;
}
);
this.commentCollection.create(options);
this.$('input, textarea').val('');
}
});
146. var CommentFormView = Backbone.View.extend({
events: {
'submit form': 'newComment'
},
initialize: function (options) { /* … */ },
render: function () { /* … */ },
newComment: function (e) {
var options, comment;
e.preventDefault();
options = {};
_.each(
this.$('form').serializeArray(),
function (field) {
options[field.name] = field.value;
}
);
this.commentCollection.create(options);
this.$('input, textarea').val('');
}
});
147. var CommentFormView = Backbone.View.extend({
events: {
'submit form': 'newComment'
},
initialize: function (options) { /* … */ },
render: function () { /* … */ },
newComment: function (e) {
var options, comment;
e.preventDefault();
options = {};
_.each(
this.$('form').serializeArray(),
function (field) {
options[field.name] = field.value;
}
);
this.commentCollection.create(options);
this.$('input, textarea').val('');
}
});
148. var CommentFormView = Backbone.View.extend({
events: {
'submit form': 'newComment'
},
initialize: function (options) { /* … */ },
render: function () { /* … */ },
newComment: function (e) {
var options, comment;
e.preventDefault();
options = {};
_.each(
this.$('form').serializeArray(),
function (field) {
options[field.name] = field.value;
}
);
this.commentCollection.create(options);
this.$('input, textarea').val('');
}
});
149. var CommentFormView = Backbone.View.extend({
events: {
'submit form': 'newComment'
},
initialize: function (options) { /* … */ },
render: function () { /* … */ },
newComment: function (e) {
var options, comment;
e.preventDefault();
options = {};
_.each(
this.$('form').serializeArray(),
function (field) {
options[field.name] = field.value;
}
);
this.commentCollection.create(options);
this.$('input, textarea').val('');
}
});