Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 44 additions & 4 deletions 07-VUES-ET-TEMPLATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ Et là, l’affichage s’actualise automatiquement :
Modifions une nouvelle fois notre vue en ajoutant le code suivant à la méthode `initialize` :

```javascript
_.bindAll(this, 'render');
this.collection.bind('reset', this.render);
this.listenTo(this.collection, 'all', 'render');
this.listenTo(this.collection, 'reset', this.render);
```

Nous venons d’expliquer que tous les événements déclarés déclencheront la méthode `render` de la vue. Et ensuite nous avons expliqué que la méthode `reset` de la collection déclenchera la méthode `render` de la vue.
Expand All @@ -283,8 +283,13 @@ window.PostsListView = Backbone.View.extend({
initialize: function(data) {
this.collection = data;

_.bindAll(this, 'render');
this.collection.bind('reset', this.render);

_.bindAll(this, 'render');
this.collection.bind('reset', this.render);

// Backbone 1.3.3
/*this.listenTo(this.collection, 'all', this.render);
this.listenTo(this.collection, 'reset', this.render);*/

},
render: function() {
Expand Down Expand Up @@ -419,6 +424,13 @@ window.PostsListView = Backbone.View.extend({
this.collection.bind('change', this.render);
this.collection.bind('add', this.render);
this.collection.bind('remove', this.render);

// Backbone 1.3.3
/*this.listenTo(this.collection, 'all', this.render);
this.listenTo(this.collection, 'reset', this.render);
this.listenTo(this.collection, 'change', this.render);
this.listenTo(this.collection, 'add', this.render);
this.listenTo(this.collection, 'remove', this.render);*/

},
render: function() {
Expand Down Expand Up @@ -490,6 +502,13 @@ $(function() {
this.collection.bind('change', this.render);
this.collection.bind('add', this.render);
this.collection.bind('remove', this.render);

// Backbone 1.3.3
/*this.listenTo(this.collection, 'all', this.render);
this.listenTo(this.collection, 'reset', this.render);
this.listenTo(this.collection, 'change', this.render);
this.listenTo(this.collection, 'add', this.render);
this.listenTo(this.collection, 'remove', this.render);*/

},
render: function() {
Expand Down Expand Up @@ -564,6 +583,13 @@ window.PostsListView = Backbone.View.extend({
this.collection.bind('change', this.render);
this.collection.bind('add', this.render);
this.collection.bind('remove', this.render);

// Backbone 1.3.3
/*this.listenTo(this.collection, 'all', this.render);
this.listenTo(this.collection, 'reset', this.render);
this.listenTo(this.collection, 'change', this.render);
this.listenTo(this.collection, 'add', this.render);
this.listenTo(this.collection, 'remove', this.render);*/

},
render: function() {
Expand Down Expand Up @@ -694,6 +720,13 @@ window.MainView = Backbone.View.extend({
this.collection.bind('change', this.render);
this.collection.bind('add', this.render);
this.collection.bind('remove', this.render);

// Backbone 1.3.3
/*this.listenTo(this.collection, 'all', this.render);
this.listenTo(this.collection, 'reset', this.render);
this.listenTo(this.collection, 'change', this.render);
this.listenTo(this.collection, 'add', this.render);
this.listenTo(this.collection, 'remove', this.render);*/

this.sidebarView = new SidebarView();
this.postsListView = new PostsListView({
Expand Down Expand Up @@ -771,6 +804,13 @@ window.MainView = Backbone.View.extend({
this.collection.bind('change', this.render);
this.collection.bind('add', this.render);
this.collection.bind('remove', this.render);

// Backbone 1.3.3
/*this.listenTo(this.collection, 'all', this.render);
this.listenTo(this.collection, 'reset', this.render);
this.listenTo(this.collection, 'change', this.render);
this.listenTo(this.collection, 'add', this.render);
this.listenTo(this.collection, 'remove', this.render);*/

this.sidebarView = new SidebarView();
this.postsListView = new PostsListView({
Expand Down