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.
This commit is contained in:
Max Goodman
2013-05-20 18:33:01 -07:00
parent eeb1d6f2ea
commit 57acac7ab0

View File

@@ -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() {