JSDay Italy - Backbone.js
Upcoming SlideShare
Loading in...5
×
 

JSDay Italy - Backbone.js

on

  • 3,198 views

 

Statistics

Views

Total Views
3,198
Views on SlideShare
2,419
Embed Views
779

Actions

Likes
6
Downloads
57
Comments
0

6 Embeds 779

http://www.scoop.it 561
http://2012.jsday.it 213
http://us-w1.rockmelt.com 2
http://nodeslide.herokuapp.com 1
https://si0.twimg.com 1
http://webcache.googleusercontent.com 1

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

JSDay Italy - Backbone.js JSDay Italy - Backbone.js Presentation Transcript

  • 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!
  • 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!
  • 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!
  • 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!
  • 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!
  • 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!
  • 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!
  • 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!
  • 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!
  • var Animal = Backbone.Model.extend({ say: function () {}});var Dog = Animal.extend({ bark: function () {}});
  • var Animal = Backbone.Model.extend({ say: function () {}});var Dog = Animal.extend({ bark: function () {}});
  • var Animal = Backbone.Model.extend({ say: function () {}});var Dog = Animal.extend({ bark: function () {}});
  • var Animal = Backbone.Model.extend({ say: function () {}});var Dog = Animal.extend({ bark: function () {}});
  • var Animal = Backbone.Model.extend({ say: function () {}});var Dog = Animal.extend({ bark: function () {}});
  • var Animal = Backbone.Model.extend({ say: function () {}});var Dog = Animal.extend({ bark: function () {}});
  • var Dog = Animal.extend({ bark: function () {}});var myDog = new Dog({ name: Bello});
  • var Dog = Animal.extend({ bark: function () {}});var myDog = new Dog({ name: Bello});
  • // 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;
  • // 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;
  • // 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;
  • // 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;
  • // 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;
  • var AppRouter = Backbone.Router.extend({ routes: { : index, q?:query: query, show/:id: show }, index: function () {}, query: function (queryString) {}, show: function (id) {}});
  • var AppRouter = Backbone.Router.extend({ routes: { : index, q?:query: query, show/:id: show }, index: function () {}, query: function (queryString) {}, show: function (id) {}});
  • var AppRouter = Backbone.Router.extend({ routes: { : index, q?:query: query, show/:id: show }, index: function () {}, query: function (queryString) {}, show: function (id) {}});
  • var AppRouter = Backbone.Router.extend({ routes: { : index, q?:query: query, show/:id: show }, index: function () {}, query: function (queryString) {}, show: function (id) {}});
  • var AppRouter = Backbone.Router.extend({ routes: { : index, q?:query: query, show/:id: show }, index: function () {}, query: function (queryString) {}, show: function (id) {}});
  • var AppRouter = Backbone.Router.extend({ routes: { : index, q?:query: query, show/:id: show }, index: function () {}, query: function (queryString) {}, show: function (id) {}});
  • var AppRouter = Backbone.Router.extend({ routes: { : index, q?:query: query, show/:id: show }, index: function () {}, query: function (queryString) {}, show: function (id) {}});
  • var AppRouter = Backbone.Router.extend({ routes: { : index, q?:query: query, show/:id: show }, index: function () {}, query: function (queryString) {}, show: function (id) {}});
  • var AppRouter = Backbone.Router.extend({ routes: { : index, q?:query: query, show/:id: show }, index: function () {}, query: function (queryString) {}, show: function (id) {}});
  • var AppRouter = Backbone.Router.extend({ routes: { : index, q?:query: query, show/:id: show }, index: function () {}, query: function (queryString) {}, show: function (id) {}});
  • Backbone.Router.extend({ routes: { /* matches search/pierre/zurich */ search/:who/:where: serach, /* matches download/avatar/@shvi/large */ download/*path: download } search: function (who, where) {}, download: function (path) {}});
  • Backbone.Router.extend({ routes: { /* matches search/pierre/zurich */ search/:who/:where: serach, /* matches download/avatar/@shvi/large */ download/*path: download } search: function (who, where) {}, download: function (path) {}});
  • var AppRouter = Backbone.Router.extend({ // …});new AppRouter();Backbone.history.start();
  • var AppRouter = Backbone.Router.extend({ // …});new AppRouter();Backbone.history.start();
  • var AppRouter = Backbone.Router.extend({ // …});new AppRouter();Backbone.history.start();
  • var Comment = Backbone.Model.extend({});var newComment = new Comment({ name: Pierre Spring, email: pierre@nelm.io, text: Hello World});
  • var Comment = Backbone.Model.extend({});var newComment = new Comment({ name: Pierre Spring, email: pierre@nelm.io, text: Hello World});
  • var Comment = Backbone.Model.extend({});var newComment = new Comment({ name: Pierre Spring, email: pierre@nelm.io, text: Hello World});
  • var Comment = Backbone.Model.extend({});var newComment = new Comment({ name: Pierre Spring, email: pierre@nelm.io, text: Hello World});
  • var Comment = Backbone.Model.extend({});var newComment = new Comment({ name: Pierre Spring, email: pierre@nelm.io, text: Hello World});
  • var Comment = Backbone.Model.extend({});var newComment = new Comment({ name: Pierre Spring, email: pierre@nelm.io, text: Hello World});
  • var newComment = new Comment({ text: Hello World});newComment.set({ name: Pierre Spring, email: pierre@nelm.io});newComment.get(name); // Pierre Spring
  • var newComment = new Comment({ text: Hello World});newComment.set({ name: Pierre Spring, email: pierre@nelm.io});newComment.get(name); // Pierre Spring
  • var newComment = new Comment({ text: Hello World});newComment.set({ name: Pierre Spring, email: pierre@nelm.io});newComment.get(name); // Pierre Spring
  • var newComment = new Comment({ text: Hello World});newComment.set({ name: Pierre Spring, email: pierre@nelm.io});newComment.get(name); // Pierre Spring
  • var Comment = Backbone.Model.extend({});var newComment = new Comment({ /* … */ });newComment.save();
  • var Comment = Backbone.Model.extend({ url: /api/comment/});var newComment = new Comment({ /* … */ });newComment.save();
  • var Comment = Backbone.Model.extend({ localStorage: new Store("comment")});var newComment = new Comment({ /* … */ });newComment.save();
  • var Comment = Backbone.Model.extend({ localStorage: new Store("comment"), initialize: function (options) { }});var newComment = new Comment({ /* … */ });newComment.save();
  • 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();
  • 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();
  • 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();
  • 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(); }});
  • 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(); }});
  • 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(); }});
  • 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(); }});
  • var newComment = new Comment({ /* … */ });newComment.getDisplayDate();// a few seconds ago
  • Backbone.Collection.extend({ model: CommentModel, localStorage: new Store("comment")});
  • Backbone.Collection.extend({ model: CommentModel, localStorage: new Store("comment")});
  • Backbone.Collection.extend({ model: CommentModel, localStorage: new Store("comment")});
  • Backbone.Collection.extend({ model: CommentModel, localStorage: new Store("comment")});
  • Backbone.Collection.extend({ model: CommentModel, localStorage: new Store("comment")});
  • var CommentCollection = Backbone.Collection.extend({ /* … */});var commentCollection = new CommentCollection();commentCollection.fetch();commentCollection.each(function (commentModel) { // do s.th.});
  • var CommentCollection = Backbone.Collection.extend({ /* … */});var commentCollection = new CommentCollection();commentCollection.fetch();commentCollection.each(function (commentModel) { // do s.th.});
  • var CommentCollection = Backbone.Collection.extend({ /* … */});var commentCollection = new CommentCollection();commentCollection.fetch();commentCollection.each(function (commentModel) { // do s.th.});
  • var CommentCollection = Backbone.Collection.extend({ /* … */});var commentCollection = new CommentCollection();commentCollection.fetch();commentCollection.each(function (commentModel) { // do s.th.});
  • var CommentCollection = Backbone.Collection.extend({ /* … */});var commentCollection = new CommentCollection();commentCollection.fetch();commentCollection.each(function (commentModel) { // do s.th.});
  • var newComment = new Comment({ /* … */ });newComment.save();commentCollection.add(newComment);
  • var newComment = new Comment({ /* … */ });newComment.save();commentCollection.add(newComment);
  • var newComment = new Comment({ /* … */ });newComment.save();commentCollection.add(newComment);
  • var newComment = new Comment({ /* … */ });newComment.save();commentCollection.add(newComment);
  • var newComment = new Comment({ /* … */ });newComment.save();commentCollection.add(newComment);var newComment = commentCollection.create({ /* model attributes */});
  • newComment.bind( change, function (model) {});newComment.bind( change:name, function (model, attribute) {});commentCollection.bind( reset, function (commentCollection) {});commentCollection.bind( add, function (commentModel) {});
  • newComment.bind( change, function (model) {});newComment.bind( change:name, function (model, attribute) {});commentCollection.bind( reset, function (commentCollection) {});commentCollection.bind( add, function (commentModel) {});
  • newComment.bind( change, function (model) {});newComment.bind( change:name, function (model, attribute) {});commentCollection.bind( reset, function (commentCollection) {});commentCollection.bind( add, function (commentModel) {});
  • newComment.bind( change, function (model) {});newComment.bind( change:name, function (model, attribute) {});commentCollection.bind( reset, function (commentCollection) {});commentCollection.bind( add, function (commentModel) {});
  • newComment.bind( change, function (model) {});newComment.bind( change:name, function (model, attribute) {});commentCollection.bind( reset, function (commentCollection) {});commentCollection.bind( add, function (commentModel) {});
  • newComment.bind( change, function (model) {});newComment.bind( change:name, function (model, attribute) {});commentCollection.bind( reset, function (commentCollection) {});commentCollection.bind( add, function (commentModel) {});
  • newComment.bind( change, function (model) {});newComment.bind( change:name, function (model, attribute) {});commentCollection.bind( reset, function (commentCollection) {});commentCollection.bind( add, function (commentModel) {});
  • newComment.bind( change, function (model) {});newComment.bind( change:name, function (model, attribute) {});commentCollection.bind( reset, function (commentCollection) {});commentCollection.bind( add, function (commentModel) {});
  • newComment.bind( change, function (model) {});newComment.bind( change:name, function (model, attribute) {});commentCollection.bind( reset, function (commentCollection) {});commentCollection.bind( add, function (commentModel) {});
  • newComment.bind( change, function (model) {});newComment.bind( change:name, function (model, attribute) {});commentCollection.bind( reset, function (commentCollection) {});commentCollection.bind( add, function (commentModel) {});
  • newComment.bind( change, function (model) {});newComment.bind( change:name, function (model, attribute) {});commentCollection.bind( reset, function (commentCollection) {});commentCollection.bind( add, function (commentModel) {});
  • var CommentView = Backbone.View.extend({});var commentView = new CommentView();console.log(commentView.el);// <div></div>
  • var CommentView = Backbone.View.extend({});var commentView = new CommentView();console.log(commentView.el);// <div></div>
  • var CommentView = Backbone.View.extend({});var commentView = new CommentView();console.log(commentView.el);// <div></div>
  • var CommentView = Backbone.View.extend({});var commentView = new CommentView();console.log(commentView.el);// <div></div>
  • var CommentView = Backbone.View.extend({});var commentView = new CommentView();console.log(commentView.el);// <div></div>
  • var CommentView = Backbone.View.extend({ tagName: p, className: comment-list, id: container,});var commentView = new CommentView();console.log(commentView.el);// <p id=​"container" class=​"comment-list"/>
  • var CommentView = Backbone.View.extend({ tagName: p, className: comment-list, id: container,});var commentView = new CommentView();console.log(commentView.el);// <p id=​"container" class=​"comment-list"/>
  • var CommentView = Backbone.View.extend({ tagName: p, className: comment-list, id: container,});var commentView = new CommentView();console.log(commentView.el);// <p id=​"container" class=​"comment-list"/>
  • var CommentView = Backbone.View.extend({ tagName: p, className: comment-list, id: container,});var commentView = new CommentView();console.log(commentView.el);// <p id=​"container" class=​"comment-list"/>
  • var CommentView = Backbone.View.extend({ el: $(#comment-list)});var commentView = new CommentView();console.log(commentView.el);
  • var CommentView = Backbone.View.extend({ initialize: function (options) { this.listRowTemplate = _.template($(#listRowTemplate).html()); options.commentCollection.bind(reset, this.renderRows, this); options.commentCollection.bind(add, this.renderRow, this); }, renderRows: function (commentCollection) { commentCollection.each(function (commentModel) { this.renderRow(commentModel); }, this); }, renderRow: function (commentModel) { $(this.el).prepend( this.listRowTemplate({ comment: commentModel.toJSON() }) ); }});
  • var CommentView = Backbone.View.extend({ initialize: function (options) { this.listRowTemplate = _.template($(#listRowTemplate).html()); options.commentCollection.bind(reset, this.renderRows, this); options.commentCollection.bind(add, this.renderRow, this); }, renderRows: function (commentCollection) { commentCollection.each(function (commentModel) { this.renderRow(commentModel); }, this); }, renderRow: function (commentModel) { $(this.el).prepend( this.listRowTemplate({ comment: commentModel.toJSON() }) ); }});
  • var CommentView = Backbone.View.extend({ initialize: function (options) { this.listRowTemplate = _.template($(#listRowTemplate).html()); options.commentCollection.bind(reset, this.renderRows, this); options.commentCollection.bind(add, this.renderRow, this); }, renderRows: function (commentCollection) { commentCollection.each(function (commentModel) { this.renderRow(commentModel); }, this); }, renderRow: function (commentModel) { $(this.el).prepend( this.listRowTemplate({ comment: commentModel.toJSON() }) ); }});
  • var CommentView = Backbone.View.extend({ initialize: function (options) { this.listRowTemplate = _.template($(#listRowTemplate).html()); options.commentCollection.bind(reset, this.renderRows, this); options.commentCollection.bind(add, this.renderRow, this); }, renderRows: function (commentCollection) { commentCollection.each(function (commentModel) { this.renderRow(commentModel); }, this); }, renderRow: function (commentModel) { $(this.el).prepend( this.listRowTemplate({ comment: commentModel.toJSON() }) ); }});
  • var CommentView = Backbone.View.extend({ initialize: function (options) { this.listRowTemplate = _.template($(#listRowTemplate).html()); options.commentCollection.bind(reset, this.renderRows, this); options.commentCollection.bind(add, this.renderRow, this); }, renderRows: function (commentCollection) { commentCollection.each(function (commentModel) { this.renderRow(commentModel); }, this); }, renderRow: function (commentModel) { $(this.el).prepend( this.listRowTemplate({ comment: commentModel.toJSON() }) ); }});
  • var CommentView = Backbone.View.extend({ initialize: function (options) { this.listRowTemplate = _.template($(#listRowTemplate).html()); options.commentCollection.bind(reset, this.renderRows, this); options.commentCollection.bind(add, this.renderRow, this); }, renderRows: function (commentCollection) { commentCollection.each(function (commentModel) { this.renderRow(commentModel); }, this); }, renderRow: function (commentModel) { $(this.el).prepend( this.listRowTemplate({ comment: commentModel.toJSON() }) ); }});
  • var CommentView = Backbone.View.extend({ initialize: function (options) { this.listRowTemplate = _.template($(#listRowTemplate).html()); options.commentCollection.bind(reset, this.renderRows, this); options.commentCollection.bind(add, this.renderRow, this); }, renderRows: function (commentCollection) { commentCollection.each(function (commentModel) { this.renderRow(commentModel); }, this); }, renderRow: function (commentModel) { $(this.el).prepend( this.listRowTemplate({ comment: commentModel.toJSON() }) ); }});
  • var CommentView = Backbone.View.extend({ initialize: function (options) { this.listRowTemplate = _.template($(#listRowTemplate).html()); options.commentCollection.bind(reset, this.renderRows, this); options.commentCollection.bind(add, this.renderRow, this); }, renderRows: function (commentCollection) { commentCollection.each(function (commentModel) { this.renderRow(commentModel); }, this); }, renderRow: function (commentModel) { $(this.el).prepend( this.listRowTemplate({ comment: commentModel.toJSON() }) ); }});
  • var commentCollection = new commentCollection();var commentView = new CommentView({ commentCollection: commentCollection});
  • var commentCollection = new commentCollection();var commentView = new CommentView({ commentCollection: commentCollection});
  • var CommentView = Backbone.View.extend({ initialize: function (options) { this.listRowTemplate = _.template($(#listRowTemplate).html()); options.commentCollection.bind(reset, this.renderRows, this); options.commentCollection.bind(add, this.renderRow, this); }, renderRows: function (commentCollection) { commentCollection.each(function (commentModel) { this.renderRow(commentModel); }, this); }, renderRow: function (commentModel) { $(this.el).prepend( this.listRowTemplate({ comment: commentModel.toJSON() }) ); }});
  • var CommentView = Backbone.View.extend({ initialize: function (options) { this.listRowTemplate = _.template($(#listRowTemplate).html()); options.commentCollection.bind(reset, this.renderRows, this); options.commentCollection.bind(add, this.renderRow, this); }, renderRows: function (commentCollection) { commentCollection.each(function (commentModel) { this.renderRow(commentModel); }, this); }, renderRow: function (commentModel) { $(this.el).prepend( this.listRowTemplate({ comment: commentModel.toJSON() }) ); }});
  • var CommentView = Backbone.View.extend({ initialize: function (options) { this.listRowTemplate = _.template($(#listRowTemplate).html()); options.commentCollection.bind(reset, this.renderRows, this); options.commentCollection.bind(add, this.renderRow, this); }, renderRows: function (commentCollection) { commentCollection.each(function (commentModel) { this.renderRow(commentModel); }, this); }, renderRow: function (commentModel) { $(this.el).prepend( this.listRowTemplate({ comment: commentModel.toJSON() }) ); }});
  • var CommentView = Backbone.View.extend({ initialize: function (options) { this.listRowTemplate = _.template($(#listRowTemplate).html()); options.commentCollection.bind(reset, this.renderRows, this); options.commentCollection.bind(add, this.renderRow, this); }, renderRows: function (commentCollection) { commentCollection.each(function (commentModel) { this.renderRow(commentModel); }, this); }, renderRow: function (commentModel) { $(this.el).prepend( this.listRowTemplate({ comment: commentModel.toJSON() }) ); }});
  • var CommentView = Backbone.View.extend({ initialize: function (options) { this.listRowTemplate = _.template($(#listRowTemplate).html()); options.commentCollection.bind(reset, this.renderRows, this); options.commentCollection.bind(add, this.renderRow, this); }, renderRows: function (commentCollection) { commentCollection.each(function (commentModel) { this.renderRow(commentModel); }, this); }, renderRow: function (commentModel) { $(this.el).prepend( this.listRowTemplate({ comment: commentModel.toJSON() }) ); }});
  • var CommentView = Backbone.View.extend({ initialize: function (options) { this.listRowTemplate = _.template($(#listRowTemplate).html()); options.commentCollection.bind(reset, this.renderRows, this); options.commentCollection.bind(add, this.renderRow, this); }, renderRows: function (commentCollection) { commentCollection.each(function (commentModel) { this.renderRow(commentModel); }, this); }, renderRow: function (commentModel) { $(this.el).prepend( this.listRowTemplate({ comment: commentModel.toJSON() }) ); }});
  • var CommentView = Backbone.View.extend({ initialize: function (options) { this.listRowTemplate = _.template($(#listRowTemplate).html()); options.commentCollection.bind(reset, this.renderRows, this); options.commentCollection.bind(add, this.renderRow, this); }, renderRows: function (commentCollection) { commentCollection.each(function (commentModel) { this.renderRow(commentModel); }, this); }, renderRow: function (commentModel) { $(this.el).prepend( this.listRowTemplate({ comment: commentModel.toJSON() }) ); }});
  • var CommentView = Backbone.View.extend({ initialize: function (options) { this.listRowTemplate = _.template($(#listRowTemplate).html()); options.commentCollection.bind(reset, this.renderRows, this); options.commentCollection.bind(add, this.renderRow, this); }, renderRows: function (commentCollection) { commentCollection.each(function (commentModel) { this.renderRow(commentModel); }, this); }, renderRow: function (commentModel) { $(this.el).prepend( this.listRowTemplate({ comment: commentModel.toJSON() }) ); }});
  • var CommentView = Backbone.View.extend({ initialize: function (options) { this.listRowTemplate = _.template($(#listRowTemplate).html()); options.commentCollection.bind(reset, this.renderRows, this); options.commentCollection.bind(add, this.renderRow, this); }, renderRows: function (commentCollection) { commentCollection.each(function (commentModel) { this.renderRow(commentModel); }, this); }, renderRow: function (commentModel) { $(this.el).prepend( this.listRowTemplate({ comment: commentModel.toJSON() }) ); }});
  • var CommentView = Backbone.View.extend({ initialize: function (options) { this.listRowTemplate = _.template($(#listRowTemplate).html()); options.commentCollection.bind(reset, this.renderRows, this); options.commentCollection.bind(add, this.renderRow, this); }, renderRows: function (commentCollection) { commentCollection.each(function (commentModel) { this.renderRow(commentModel); }, this); }, renderRow: function (commentModel) { $(this.el).prepend( this.listRowTemplate({ comment: commentModel.toJSON() }) ); }});
  • var CommentView = Backbone.View.extend({ initialize: function (options) { this.listRowTemplate = _.template($(#listRowTemplate).html()); options.commentCollection.bind(reset, this.renderRows, this); options.commentCollection.bind(add, this.renderRow, this); }, renderRows: function (commentCollection) { commentCollection.each(function (commentModel) { this.renderRow(commentModel); }, this); }, renderRow: function (commentModel) { $(this.el).prepend( this.listRowTemplate({ comment: commentModel.toJSON() }) ); }});
  • var CommentView = Backbone.View.extend({ initialize: function (options) { this.listRowTemplate = _.template($(#listRowTemplate).html()); options.commentCollection.bind(reset, this.renderRows, this); options.commentCollection.bind(add, this.renderRow, this); }, renderRows: function (commentCollection) { commentCollection.each(function (commentModel) { this.renderRow(commentModel); }, this); }, renderRow: function (commentModel) { $(this.el).prepend( this.listRowTemplate({ comment: commentModel.toJSON() }) ); }});
  • var CommentView = Backbone.View.extend({ initialize: function (options) { this.listRowTemplate = _.template($(#listRowTemplate).html()); options.commentCollection.bind(reset, this.renderRows, this); options.commentCollection.bind(add, this.renderRow, this); }, renderRows: function (commentCollection) { commentCollection.each(function (commentModel) { this.renderRow(commentModel); }, this); }, renderRow: function (commentModel) { $(this.el).prepend( this.listRowTemplate({ comment: commentModel.toJSON() }) ); }});
  • var CommentView = Backbone.View.extend({ initialize: function (options) { this.listRowTemplate = _.template($(#listRowTemplate).html()); options.commentCollection.bind(reset, this.renderRows, this); options.commentCollection.bind(add, this.renderRow, this); }, renderRows: function (commentCollection) { commentCollection.each(function (commentModel) { this.renderRow(commentModel); }, this); }, renderRow: function (commentModel) { $(this.el).prepend( this.listRowTemplate({ comment: commentModel.toJSON() }) ); }});
  • var commentCollection = new commentCollection();var commentView = new CommentView({ commentCollection: commentCollection});$(.list-view).html(commentView.el);commentCollection.fetch();
  • var commentCollection = new commentCollection();var commentView = new CommentView({ commentCollection: commentCollection});$(.list-view).html(commentView.el);commentCollection.fetch();
  • var commentCollection = new commentCollection();var commentView = new CommentView({ commentCollection: commentCollection});$(.list-view).html(commentView.el);commentCollection.fetch();
  • var commentCollection = new commentCollection();var commentView = new CommentView({ commentCollection: commentCollection});$(.list-view).html(commentView.el);commentCollection.fetch();
  • 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(); }});
  • 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(); }});
  • 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(); }});
  • 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(); }});
  • 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(); }});
  • 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(); }});
  • 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(); }});
  • 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(); }});
  • 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(); }});
  • 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(); }});