Commit 6bad5351 by David Baumgold

Save chapter info when a new chapter is added to a textbook

parent ee1158f8
...@@ -136,7 +136,7 @@ CMS.Views.TextbookEdit = Backbone.View.extend({ ...@@ -136,7 +136,7 @@ CMS.Views.TextbookEdit = Backbone.View.extend({
return this; return this;
}, },
events: { events: {
"submit": "save", "submit": "saveAndRemove",
"click .action-cancel": "cancel", "click .action-cancel": "cancel",
"click .action-add-chapter": "createChapter" "click .action-add-chapter": "createChapter"
}, },
...@@ -150,10 +150,10 @@ CMS.Views.TextbookEdit = Backbone.View.extend({ ...@@ -150,10 +150,10 @@ CMS.Views.TextbookEdit = Backbone.View.extend({
}, },
createChapter: function(e) { createChapter: function(e) {
if(e && e.preventDefault) { e.preventDefault(); } if(e && e.preventDefault) { e.preventDefault(); }
this.save();
this.model.chapters.add([{}]) this.model.chapters.add([{}])
}, },
save: function(e) { save: function() {
if(e && e.preventDefault) { e.preventDefault(); }
var name = this.$("#textbook-name-input").val(); var name = this.$("#textbook-name-input").val();
var textbook = this.model; var textbook = this.model;
textbook.set("name", name); textbook.set("name", name);
...@@ -164,9 +164,12 @@ CMS.Views.TextbookEdit = Backbone.View.extend({ ...@@ -164,9 +164,12 @@ CMS.Views.TextbookEdit = Backbone.View.extend({
"asset_path": $(".chapter-asset-path", li).val() "asset_path": $(".chapter-asset-path", li).val()
}) })
}); });
this.remove();
return this; return this;
}, },
saveAndRemove: function(e) {
if(e && e.preventDefault) { e.preventDefault(); }
return this.save().remove();
},
cancel: function(e) { cancel: function(e) {
if(e && e.preventDefault) { e.preventDefault(); } if(e && e.preventDefault) { e.preventDefault(); }
this.remove(); this.remove();
......
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