Prevent overzealous requesting of partials while editing pages
This commit is contained in:
parent
9a730a947e
commit
b13f766176
|
@ -82,6 +82,7 @@ var deletePage = function() {
|
||||||
bootbox.alert('Error deleting page!');
|
bootbox.alert('Error deleting page!');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
var last_imports = '';
|
||||||
var partials = [];
|
var partials = [];
|
||||||
var aced = new Aced({
|
var aced = new Aced({
|
||||||
editor: $('#entry-markdown-content').find('.editor').attr('id'),
|
editor: $('#entry-markdown-content').find('.editor').attr('id'),
|
||||||
|
@ -89,8 +90,8 @@ var aced = new Aced({
|
||||||
var doc = metaMarked(md);
|
var doc = metaMarked(md);
|
||||||
if (doc.meta && 'import' in doc.meta) {
|
if (doc.meta && 'import' in doc.meta) {
|
||||||
// If the imports have changed, refresh them from the server
|
// If the imports have changed, refresh them from the server
|
||||||
if (partials.length < doc.meta['import'].length ||
|
if (doc.meta['import'].toString() != last_imports) {
|
||||||
!doc.meta['import'].every(function(impname, index) {return partials[partials.length-index-1][0] == impname})) {
|
last_imports = doc.meta['import'].toString();
|
||||||
$.getJSON('/_partials', {'imports': doc.meta['import']}, function (response) {
|
$.getJSON('/_partials', {'imports': doc.meta['import']}, function (response) {
|
||||||
partials = response['partials'];
|
partials = response['partials'];
|
||||||
// TODO: Better way to force update of the preview here than this fake signal?
|
// TODO: Better way to force update of the preview here than this fake signal?
|
||||||
|
|
Loading…
Reference in a new issue