Commit ced90c23 authored by tleb's avatar tleb
Browse files

More JS-like, callback as last argument

parent 42f5773f
......@@ -14,14 +14,12 @@
}
// Custom markdown parser
function customMarkdownParser(plainText, preview) {
function customMarkdownParser(plainText, cb) {
$.ajax({
url: "{{ markdown_api_url }}",
method: "POST",
data: { text: plainText, csrfmiddlewaretoken: getCSRFToken() },
}).done(function (msg) {
preview.innerHTML = msg;
});
}).done(cb);
}
// Pretty markdown input
......@@ -31,9 +29,9 @@
autoDownloadFontAwesome: false,
previewRender: function(plainText, preview){ // Async method
clearTimeout(lastAPICall);
lastAPICall = setTimeout(function (plainText, preview){
customMarkdownParser(plainText, preview);
}, 300, plainText, preview);
lastAPICall = setTimeout(() => {
customMarkdownParser(plainText, (msg) => preview.innerHTML = msg);
}, 300);
return preview.innerHTML;
},
forceSync: true, // Avoid validation error on generic create view
......@@ -169,4 +167,4 @@
]
});
</script>
</div>
\ No newline at end of file
</div>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment