Permalink
Browse files

update ranks when removing a cat

  • Loading branch information...
davidsulc committed Apr 20, 2012
1 parent f0befae commit e8e1870d59db967a8ac312b30dabad410fca73c7
Showing with 11 additions and 0 deletions.
  1. +11 −0 assets/javascripts/application.js
@@ -59,6 +59,16 @@ AngryCats = Backbone.Collection.extend({
self.rankDown(cat);
self.sort();
});
+
+ MyApp.vent.on("cat:disqualify", function(cat){
+ var disqualifiedRank = cat.get('rank');
+ var catsToUprank = self.filter(
+ function(cat){ return cat.get('rank') > disqualifiedRank; }
+ );
+ catsToUprank.forEach(function(cat){
+ cat.rankUp();
+ });
+ });
},
comparator: function(cat) {
@@ -112,6 +122,7 @@ AngryCatView = Backbone.Marionette.ItemView.extend({
},
disqualify: function(){
+ MyApp.vent.trigger("cat:disqualify", this.model);
this.model.destroy();
}
});

0 comments on commit e8e1870

Please sign in to comment.