From 7d2c6339bcaac5826e2d101387c4cdded15aea0d Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 5 Oct 2013 16:55:32 -0700 Subject: [PATCH] EpisodeActivity cleanup --- .../Episode/Activity/EpisodeActivityCollection.js | 13 +++++-------- src/UI/Episode/Activity/EpisodeActivityLayout.js | 11 +++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/UI/Episode/Activity/EpisodeActivityCollection.js b/src/UI/Episode/Activity/EpisodeActivityCollection.js index 968286c08..3ae1693b8 100644 --- a/src/UI/Episode/Activity/EpisodeActivityCollection.js +++ b/src/UI/Episode/Activity/EpisodeActivityCollection.js @@ -11,18 +11,15 @@ define( originalFetch: Backbone.Collection.prototype.fetch, initialize: function (options) { + if (!options.episodeId) { + throw 'episodeId is required'; + } + this.episodeId = options.episodeId; }, fetch: function (options) { - if (!this.episodeId) { - throw 'episodeId is required'; - } - - if (!options) { - options = {}; - } - + options = options || {}; options.data = { episodeId: this.episodeId }; return this.originalFetch.call(this, options); diff --git a/src/UI/Episode/Activity/EpisodeActivityLayout.js b/src/UI/Episode/Activity/EpisodeActivityLayout.js index 1a451391e..50c3f08ba 100644 --- a/src/UI/Episode/Activity/EpisodeActivityLayout.js +++ b/src/UI/Episode/Activity/EpisodeActivityLayout.js @@ -48,17 +48,12 @@ define( this.series = options.series; this.collection = new EpisodeActivityCollection({ episodeId: this.model.id }); + this.collection.fetch(); + this.listenTo(this.collection, 'sync', this._showTable); }, - onShow: function () { - var self = this; + onRender: function () { this.activityTable.show(new LoadingView()); - - var promise = this.collection.fetch(); - - promise.done(function () { - self._showTable(); - }); }, _showTable: function () {