From 64adb62d48d54ccf8bccdf1cc93edcd692f2474a Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Tue, 11 Jun 2013 17:08:32 -0400 Subject: [PATCH] make sure to save textbook name when it changes --- cms/templates/js/textbook-edit.underscore | 2 +- cms/templates/textbooks.html | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cms/templates/js/textbook-edit.underscore b/cms/templates/js/textbook-edit.underscore index 12733f4be9..07d12739f7 100644 --- a/cms/templates/js/textbook-edit.underscore +++ b/cms/templates/js/textbook-edit.underscore @@ -8,7 +8,7 @@ <%= gettext("Textbook information") %>
- " value="<%= name %>"> + " value="<%= name %>"> <%= gettext("the title/name of the text book as you would like your students to see it.") %>
diff --git a/cms/templates/textbooks.html b/cms/templates/textbooks.html index b46e0f73a4..528f9bc510 100644 --- a/cms/templates/textbooks.html +++ b/cms/templates/textbooks.html @@ -120,6 +120,7 @@ CMS.Views.TextbookEdit = Backbone.View.extend({ return this; }, events: { + "change input[name=textbook-name]": "setName", "submit": "setAndClose", "click .action-cancel": "cancel", "click .action-add-chapter": "createChapter" @@ -137,12 +138,15 @@ CMS.Views.TextbookEdit = Backbone.View.extend({ this.setValues(); this.model.get('chapters').add([{}]); }, + setName: function(e) { + if(e && e.preventDefault) { e.preventDefault(); } + this.model.set("name", this.$("#textbook-name-input").val(), {silent: true}); + }, setValues: function() { - var name = this.$("#textbook-name-input").val(); - var textbook = this.model; - textbook.set("name", name); + this.setName(); + var that = this; _.each(this.$("li"), function(li, i) { - var chapter = textbook.get('chapters').at(i); + var chapter = that.model.get('chapters').at(i); chapter.set({ "name": $(".chapter-name", li).val(), "asset_path": $(".chapter-asset-path", li).val()