From e9a8f408bffc1c64e192f8d39401d9c5f9697a6b Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Tue, 14 May 2013 16:43:41 -0400 Subject: [PATCH] Add {reset: true} to all collection.fetch() calls This is to fix a bug with the Backbone 1.0 upgrade; some views were listening to reset events that were not longer getting fired --- cms/static/js/views/checklists_view.js | 1 + cms/static/js/views/course_info_edit.js | 43 +++++++++++-------- cms/static/js/views/settings/advanced_view.js | 1 + cms/templates/course_info.html | 8 ++-- cms/templates/settings.html | 18 ++++---- 5 files changed, 39 insertions(+), 32 deletions(-) diff --git a/cms/static/js/views/checklists_view.js b/cms/static/js/views/checklists_view.js index 1ae29f99d5..b2727e58f7 100644 --- a/cms/static/js/views/checklists_view.js +++ b/cms/static/js/views/checklists_view.js @@ -22,6 +22,7 @@ CMS.Views.Checklists = Backbone.View.extend({ } ); }, + reset: true, error: CMS.ServerError } ); diff --git a/cms/static/js/views/course_info_edit.js b/cms/static/js/views/course_info_edit.js index 50793c5f1e..9554b0d7c3 100644 --- a/cms/static/js/views/course_info_edit.js +++ b/cms/static/js/views/course_info_edit.js @@ -160,11 +160,17 @@ CMS.Views.ClassInfoUpdateView = Backbone.View.extend({ var targetModel = this.eventModel(event); this.modelDom(event).remove(); var cacheThis = this; - targetModel.destroy({success : function (model, response) { - cacheThis.collection.fetch({success : function() {cacheThis.render();}, - error : CMS.ServerError}); - }, - error : CMS.ServerError + targetModel.destroy({ + success: function (model, response) { + cacheThis.collection.fetch({ + success: function() { + cacheThis.render(); + }, + reset: true, + error: CMS.ServerError + }); + }, + error : CMS.ServerError }); }, @@ -238,20 +244,19 @@ CMS.Views.ClassInfoHandoutsView = Backbone.View.extend({ initialize: function() { var self = this; - this.model.fetch( - { - complete: function() { - window.templateLoader.loadRemoteTemplate("course_info_handouts", - "/static/client_templates/course_info_handouts.html", - function (raw_template) { - self.template = _.template(raw_template); - self.render(); - } - ); - }, - error : CMS.ServerError - } - ); + this.model.fetch({ + complete: function() { + window.templateLoader.loadRemoteTemplate("course_info_handouts", + "/static/client_templates/course_info_handouts.html", + function (raw_template) { + self.template = _.template(raw_template); + self.render(); + } + ); + }, + reset: true, + error: CMS.ServerError + }); }, render: function () { diff --git a/cms/static/js/views/settings/advanced_view.js b/cms/static/js/views/settings/advanced_view.js index c1392831b8..bef908601b 100644 --- a/cms/static/js/views/settings/advanced_view.js +++ b/cms/static/js/views/settings/advanced_view.js @@ -155,6 +155,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({ self.model.clear({silent : true}); self.model.fetch({ success : function() { self.render(); }, + reset: true, error : CMS.ServerError }); }, diff --git a/cms/templates/course_info.html b/cms/templates/course_info.html index cbf436ecc5..55042ee843 100644 --- a/cms/templates/course_info.html +++ b/cms/templates/course_info.html @@ -16,18 +16,18 @@ - +