Commit 64adb62d by David Baumgold

make sure to save textbook name when it changes

parent ce26d524
......@@ -8,7 +8,7 @@
<legend class="sr"><%= gettext("Textbook information") %></legend>
<div class="input-wrap field text required add-textbook-name">
<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>
</div>
</fieldset>
......
......@@ -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()
......
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