diff --git a/js/redactor-osticket.js b/js/redactor-osticket.js index e833f347bc30fc6c3dafee57650c3867c0236058..afaf21c9ce0fdcf27ce4bc7e61dc0e912114445a 100644 --- a/js/redactor-osticket.js +++ b/js/redactor-osticket.js @@ -286,3 +286,17 @@ $(function() { $(document).on('pjax:success', findRichtextBoxes); $(document).on('pjax:start', cleanupRedactorElements); }); + +$(document).ajaxError(function(event, request, settings) { + if (settings.url.indexOf('ajax.php/draft') != -1) { + $('.richtext').each(function() { + var redactor = $(this).data('redactor'); + if (redactor) { + clearInterval(redactor.autosaveInterval); + } + }); + $('#overlay').show(); + alert('Unable to save draft. Refresh the current page to restore and continue your draft.'); + $('#overlay').hide(); + } +});