From e55bb845b26731cb1727406e9d0fe0cdccd35d38 Mon Sep 17 00:00:00 2001 From: Don Mitchell Date: Fri, 1 Mar 2013 16:05:58 -0500 Subject: [PATCH] Fix for script tags w/in json objects being oddly evaluated on html page load by doing load separately. In process, upgraded backbone which necessitated changing getByCid to get and got rid of obsolete course_settings master object. --- .../js/models/settings/course_settings.js | 42 ----------- cms/static/js/views/course_info_edit.js | 6 +- cms/templates/course_info.html | 2 +- common/static/js/vendor/backbone-min.js | 72 ++++++++++--------- 4 files changed, 42 insertions(+), 80 deletions(-) delete mode 100644 cms/static/js/models/settings/course_settings.js diff --git a/cms/static/js/models/settings/course_settings.js b/cms/static/js/models/settings/course_settings.js deleted file mode 100644 index 62b214e853..0000000000 --- a/cms/static/js/models/settings/course_settings.js +++ /dev/null @@ -1,42 +0,0 @@ -if (!CMS.Models['Settings']) CMS.Models.Settings = new Object(); -CMS.Models.Settings.CourseSettings = Backbone.Model.extend({ - // a container for the models representing the n possible tabbed states - defaults: { - courseLocation: null, - details: null, - faculty: null, - grading: null, - problems: null, - discussions: null - }, - - retrieve: function(submodel, callback) { - if (this.get(submodel)) callback(); - else { - var cachethis = this; - switch (submodel) { - case 'details': - var details = new CMS.Models.Settings.CourseDetails({location: this.get('courseLocation')}); - details.fetch( { - success : function(model) { - cachethis.set('details', model); - callback(model); - } - }); - break; - case 'grading': - var grading = new CMS.Models.Settings.CourseGradingPolicy({course_location: this.get('courseLocation')}); - grading.fetch( { - success : function(model) { - cachethis.set('grading', model); - callback(model); - } - }); - break; - - default: - break; - } - } - } -}) \ No newline at end of file diff --git a/cms/static/js/views/course_info_edit.js b/cms/static/js/views/course_info_edit.js index 277a15b57c..26fbba35a4 100644 --- a/cms/static/js/views/course_info_edit.js +++ b/cms/static/js/views/course_info_edit.js @@ -44,6 +44,8 @@ CMS.Views.ClassInfoUpdateView = Backbone.View.extend({ self.render(); } ); + // when the client refetches the updates as a whole, re-render them + this.listenTo(this.collection, 'reset', this.render); }, render: function () { @@ -150,7 +152,7 @@ CMS.Views.ClassInfoUpdateView = Backbone.View.extend({ }, closeEditor: function(self, removePost) { - var targetModel = self.collection.getByCid(self.$currentPost.attr('name')); + var targetModel = self.collection.get(self.$currentPost.attr('name')); if(removePost) { self.$currentPost.remove(); @@ -172,7 +174,7 @@ CMS.Views.ClassInfoUpdateView = Backbone.View.extend({ // Dereferencing from events to screen elements eventModel: function(event) { // not sure if it should be currentTarget or delegateTarget - return this.collection.getByCid($(event.currentTarget).attr("name")); + return this.collection.get($(event.currentTarget).attr("name")); }, modelDom: function(event) { diff --git a/cms/templates/course_info.html b/cms/templates/course_info.html index a68a0da76a..55dcaaa068 100644 --- a/cms/templates/course_info.html +++ b/cms/templates/course_info.html @@ -20,8 +20,8 @@