load file to edit async to prevent browser page caching issues

This commit is contained in:
Kyle Drake 2016-07-19 14:40:22 -07:00
parent 83ee577a14
commit 21299e3abc

View file

@ -92,7 +92,7 @@
<div class="row editor">
<div class="col col-100">
<div id="editor"><%==encoding_fix(@file_data) %></div>
<div id="editor"><h3>Loading...</h3></div>
</div>
</div>
@ -154,7 +154,9 @@
var editor = {}
$.get('/site_files/download/<%= @filename %>', function(resp) {
$(document).ready(function() {
$.get('/site_files/download/<%= @filename %>', function(resp) {
editor = ace.edit("editor")
setTheme()
<% if @ace_mode %>
@ -172,6 +174,8 @@
// Disable autocomplete
editor.setBehavioursEnabled(false)
editor.setValue(resp, -1)
editor.on('change', function(obj) {
$('a#saveButton,a#saveAndExitButton').css('opacity', 1)
unsavedChanges = true
@ -185,6 +189,8 @@
}
})
})
})
})
window.onbeforeunload = function() {
if(unsavedChanges == true)