diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 9c1a7d602..776f9931e 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -166,4 +166,11 @@ var initialize_modules = function() { App.BudgetEditAssociations.initialize(); }; +var destroy_non_idempotent_modules = function() { + "use strict"; + + App.HTMLEditor.destroy(); +}; + $(document).on("turbolinks:load", initialize_modules); +$(document).on("turbolinks:before-cache", destroy_non_idempotent_modules); diff --git a/app/assets/javascripts/html_editor.js b/app/assets/javascripts/html_editor.js index affdc7034..e1602509d 100644 --- a/app/assets/javascripts/html_editor.js +++ b/app/assets/javascripts/html_editor.js @@ -1,11 +1,6 @@ (function() { "use strict"; App.HTMLEditor = { - destroy: function() { - for (var name in CKEDITOR.instances) { - CKEDITOR.instances[name].destroy(); - } - }, initialize: function() { $("textarea.html-area").each(function() { if ($(this).hasClass("admin")) { @@ -14,8 +9,11 @@ CKEDITOR.replace(this.name, { language: $("html").attr("lang") }); } }); + }, + destroy: function() { + for (var name in CKEDITOR.instances) { + CKEDITOR.instances[name].destroy(); + } } }; - - $(document).on("turbolinks:before-cache", App.HTMLEditor.destroy); }).call(this);