1
0
Fork 0

fixed event bug in document view

This commit is contained in:
hkernbach 2017-05-16 15:19:24 +02:00
parent e1031e64f7
commit db4cdfef6a
2 changed files with 21 additions and 5 deletions

View File

@ -655,12 +655,18 @@
this.waitForInit(this.document.bind(this), colid, docid); this.waitForInit(this.document.bind(this), colid, docid);
return; return;
} }
if (!this.documentView) { var mode;
if (this.documentView) {
if (this.documentView.defaultMode) {
mode = this.documentView.defaultMode;
}
this.documentView.remove();
}
this.documentView = new window.DocumentView({ this.documentView = new window.DocumentView({
collection: this.arangoDocumentStore collection: this.arangoDocumentStore
}); });
}
this.documentView.colid = colid; this.documentView.colid = colid;
this.documentView.defaultMode = mode;
var doc = window.location.hash.split('/')[2]; var doc = window.location.hash.split('/')[2];
var test = (doc.split('%').length - 1) % 3; var test = (doc.split('%').length - 1) % 3;

View File

@ -35,6 +35,14 @@
'click #addDocument': 'addDocument' 'click #addDocument': 'addDocument'
}, },
remove: function () {
this.$el.empty().off(); /* off to unbind the events */
this.stopListening();
this.unbind();
delete this.el;
return this;
},
checkSearchBox: function (e) { checkSearchBox: function (e) {
if ($(e.currentTarget).val() === '') { if ($(e.currentTarget).val() === '') {
this.editor.expandAll(); this.editor.expandAll();
@ -208,7 +216,9 @@
iconlib: 'fontawesome4' iconlib: 'fontawesome4'
}; };
this.editor = new JSONEditor(container, options); this.editor = new JSONEditor(container, options);
if (this.defaultMode) {
this.editor.setMode(this.defaultMode); this.editor.setMode(this.defaultMode);
}
return this; return this;
}, },