Commit 64adb62d by David Baumgold

make sure to save textbook name when it changes

parent ce26d524
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<legend class="sr"><%= gettext("Textbook information") %></legend> <legend class="sr"><%= gettext("Textbook information") %></legend>
<div class="input-wrap field text required add-textbook-name"> <div class="input-wrap field text required add-textbook-name">
<label for="textbook-name-input"><%= gettext("Textbook Name") %></label> <label for="textbook-name-input"><%= gettext("Textbook Name") %></label>
<input id="textbook-name-input" type="text" placeholder="<%= gettext("Introduction to Cookie Baking") %>" value="<%= name %>"> <input id="textbook-name-input" name="textbook-name" type="text" placeholder="<%= gettext("Introduction to Cookie Baking") %>" value="<%= name %>">
<span class="tip tip-stacked"><%= gettext("the title/name of the text book as you would like your students to see it.") %></span> <span class="tip tip-stacked"><%= gettext("the title/name of the text book as you would like your students to see it.") %></span>
</div> </div>
</fieldset> </fieldset>
......
...@@ -120,6 +120,7 @@ CMS.Views.TextbookEdit = Backbone.View.extend({ ...@@ -120,6 +120,7 @@ CMS.Views.TextbookEdit = Backbone.View.extend({
return this; return this;
}, },
events: { events: {
"change input[name=textbook-name]": "setName",
"submit": "setAndClose", "submit": "setAndClose",
"click .action-cancel": "cancel", "click .action-cancel": "cancel",
"click .action-add-chapter": "createChapter" "click .action-add-chapter": "createChapter"
...@@ -137,12 +138,15 @@ CMS.Views.TextbookEdit = Backbone.View.extend({ ...@@ -137,12 +138,15 @@ CMS.Views.TextbookEdit = Backbone.View.extend({
this.setValues(); this.setValues();
this.model.get('chapters').add([{}]); 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() { setValues: function() {
var name = this.$("#textbook-name-input").val(); this.setName();
var textbook = this.model; var that = this;
textbook.set("name", name);
_.each(this.$("li"), function(li, i) { _.each(this.$("li"), function(li, i) {
var chapter = textbook.get('chapters').at(i); var chapter = that.model.get('chapters').at(i);
chapter.set({ chapter.set({
"name": $(".chapter-name", li).val(), "name": $(".chapter-name", li).val(),
"asset_path": $(".chapter-asset-path", li).val() "asset_path": $(".chapter-asset-path", li).val()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment