Commit 6e2159cb by chrisndodge

Merge pull request #1139 from MITx/fix/cdodge/code-mirror-on-course-info

more tweeks on CodeMirror. Also do a re-ordering of operations when crea...
parents da73fc77 35317b06
......@@ -69,6 +69,9 @@ CMS.Views.ClassInfoUpdateView = Backbone.View.extend({
var $newForm = $(this.template({ updateModel : newModel }));
var updateEle = this.$el.find("#course-update-list");
$(updateEle).prepend($newForm);
var $textArea = $newForm.find(".new-update-content").first();
if (this.$codeMirror == null ) {
this.$codeMirror = CodeMirror.fromTextArea($textArea.get(0), {
......@@ -78,8 +81,6 @@ CMS.Views.ClassInfoUpdateView = Backbone.View.extend({
});
}
var updateEle = this.$el.find("#course-update-list");
$(updateEle).prepend($newForm);
$newForm.addClass('editing');
this.$currentPost = $newForm.closest('li');
......@@ -94,11 +95,10 @@ CMS.Views.ClassInfoUpdateView = Backbone.View.extend({
onSave: function(event) {
var targetModel = this.eventModel(event);
console.log(this.contentEntry(event).val());
targetModel.set({ date : this.dateEntry(event).val(), content : this.$codeMirror.getValue() });
// push change to display, hide the editor, submit the change
this.closeEditor(this);
targetModel.save();
this.closeEditor(this);
},
onCancel: function(event) {
......@@ -158,9 +158,8 @@ CMS.Views.ClassInfoUpdateView = Backbone.View.extend({
self.$currentPost.find('form').hide();
window.$modalCover.unbind('click');
window.$modalCover.hide();
if (this.$codeMirror != null)
this.$codeMirror.remove();
this.$codeMirror = null;
self.$currentPost.find('.CodeMirror').remove();
},
// Dereferencing from events to screen elements
......@@ -274,8 +273,7 @@ CMS.Views.ClassInfoHandoutsView = Backbone.View.extend({
this.$form.hide();
window.$modalCover.unbind('click');
window.$modalCover.hide();
if (this.$codeMirror != null)
this.$codeMirror.remove();
self.$form.find('.CodeMirror').remove();
this.$codeMirror = null;
}
});
\ No newline at end of file
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