From 57acac7ab0af7c140baedb85e6c31f56358fddb4 Mon Sep 17 00:00:00 2001 From: Max Goodman Date: Mon, 20 May 2013 18:33:01 -0700 Subject: [PATCH] Fix multi details sidebar collection initial fetch and render. The switch from collection reset -> set caused the change handler in MultiDetails to immediately fire off a refreshListing. This change causes the collection contents to be loaded before the instantiation of the view (due to preload), and makes the view handle initial rendering of the collection contents in its constructor. --- r2/r2/public/static/js/multi.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/r2/r2/public/static/js/multi.js b/r2/r2/public/static/js/multi.js index 60f8a5138..8a5327a88 100644 --- a/r2/r2/public/static/js/multi.js +++ b/r2/r2/public/static/js/multi.js @@ -8,13 +8,14 @@ r.multi = { var detailsEl = $('.multi-details') if (detailsEl.length) { - var multi = this.multis.touch(detailsEl.data('path')), - detailsView = new r.multi.MultiDetails({ - model: multi, - el: detailsEl - }) + var multi = this.multis.touch(detailsEl.data('path')) multi.fetch() + var detailsView = new r.multi.MultiDetails({ + model: multi, + el: detailsEl + }).render() + if (location.hash == '#created') { detailsView.focusAdd() } @@ -229,14 +230,15 @@ r.multi.MultiDetails = Backbone.View.extend({ r.ui.showWorkingDeferred(this.$el, xhr) }, this) - this.$('.subreddits').empty() - this.itemViews = {} - this.bubbleGroup = {} this.addBubble = new r.multi.MultiAddNoticeBubble({ parent: this.$('.add-sr .sr-name'), trackHover: false }) + + this.itemViews = {} + this.$('.subreddits').empty() + this.model.subreddits.each(this.addOne, this) }, render: function() {