From 207cf1084b25d3b5284d00880cfd76b6a4795788 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Fri, 6 Mar 2020 15:34:43 +0100 Subject: [PATCH] Fix duplication of code when navigation back and forth --- app/assets/javascripts/editor/editor.js.erb | 5 +++-- app/views/exercises/implement.html.slim | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/editor/editor.js.erb b/app/assets/javascripts/editor/editor.js.erb index f12cfcdf..8dd5a459 100644 --- a/app/assets/javascripts/editor/editor.js.erb +++ b/app/assets/javascripts/editor/editor.js.erb @@ -782,8 +782,9 @@ configureEditors: function () { this.showFirstFile(); this.resizeAceEditors(); - $(window).on("beforeunload", this.unloadAutoSave.bind(this)); + window.addEventListener("beforeunload", this.unloadAutoSave.bind(this)); + window.addEventListener("page:before-change", this.unloadAutoSave.bind(this)); // create autosave when the editor is opened the first time - // TODO: this.autosave(); + this.autosave(); } }; diff --git a/app/views/exercises/implement.html.slim b/app/views/exercises/implement.html.slim index 2a5d030c..b6ac676f 100644 --- a/app/views/exercises/implement.html.slim +++ b/app/views/exercises/implement.html.slim @@ -1,7 +1,7 @@ - content_for :head do // Force a full page reload, see https://github.com/turbolinks/turbolinks/issues/326. Otherwise, lti_parameters might be nil - meta name='turbolinks-visit-control' content='reload' + meta name="turbolinks-cache-control" content="no-cache" .row #editor-column.col-md-12