Prevent duplication of content in ACE.
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
$(document).on('turbolinks:load', function() {
|
$(document).on('turbolinks:load', function(event) {
|
||||||
|
|
||||||
//Merge all editor components.
|
//Merge all editor components.
|
||||||
$.extend(
|
$.extend(
|
||||||
@ -14,9 +14,12 @@ $(document).on('turbolinks:load', function() {
|
|||||||
CodeOceanEditorRequestForComments
|
CodeOceanEditorRequestForComments
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($('#editor').isPresent() && CodeOceanEditor) {
|
if ($('#editor').isPresent() && CodeOceanEditor && event.originalEvent.data.url.endsWith("/implement")) {
|
||||||
if (CodeOceanEditor.isBrowserSupported()) {
|
if (CodeOceanEditor.isBrowserSupported()) {
|
||||||
$('#alert').hide();
|
$('#alert').hide();
|
||||||
|
// This call will (amon other things) initializeEditors and load the content except for the last line
|
||||||
|
// It must not be called during page navigation. Otherwise, content will be duplicated!
|
||||||
|
// Search for insertLines and Turbolinks reload / cache control
|
||||||
CodeOceanEditor.initializeEverything();
|
CodeOceanEditor.initializeEverything();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -879,7 +879,7 @@ var CodeOceanEditor = {
|
|||||||
this.initializeDeadlines();
|
this.initializeDeadlines();
|
||||||
CodeOceanEditorTips.initializeEventHandlers();
|
CodeOceanEditorTips.initializeEventHandlers();
|
||||||
|
|
||||||
window.addEventListener("turbolinks:request-start", this.unloadAutoSave.bind(this));
|
window.addEventListener("beforeunload", this.unloadAutoSave.bind(this));
|
||||||
// create autosave when the editor is opened the first time
|
// create autosave when the editor is opened the first time
|
||||||
this.autosave();
|
this.autosave();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user