reinitialize highlight.js after ajax call

This commit is contained in:
zmagod 2016-12-16 11:44:42 +01:00
parent 62e4d32221
commit 897e34a23b
2 changed files with 22 additions and 1 deletions

View file

@ -382,6 +382,7 @@ function initCallBacks() {
applyMoveStepCallBack(); applyMoveStepCallBack();
applyCollapseLinkCallBack(); applyCollapseLinkCallBack();
initDeleteStep(); initDeleteStep();
initHighlightjs();
} }
/* /*
@ -554,6 +555,14 @@ function renderTable(table) {
} }
} }
function initHighlightjs() {
if(hljs){
$('.ql-editor pre').each(function(i, block) {
hljs.highlightBlock(block);
});
}
}
function initStepsComments() { function initStepsComments() {
Comments.initialize(); Comments.initialize();
Comments.initCommentOptions("ul.content-comments"); Comments.initCommentOptions("ul.content-comments");
@ -568,6 +577,7 @@ $(document).ready(function() {
expandAllSteps(); expandAllSteps();
setupAssetsLoading(); setupAssetsLoading();
initStepsComments(); initStepsComments();
initHighlightjs();
$(function () { $(function () {

View file

@ -61,11 +61,12 @@ function formAjaxResultText($form) {
applyCollapseLinkCallBack(); applyCollapseLinkCallBack();
toggleResultEditButtons(true); toggleResultEditButtons(true);
expandResult(newResult); expandResult(newResult);
initHighlightjs();
}); });
$form.on("ajax:error", function(e, xhr, status, error) { $form.on("ajax:error", function(e, xhr, status, error) {
var data = xhr.responseJSON; var data = xhr.responseJSON;
$form.renderFormErrors("result", data); $form.renderFormErrors("result", data);
initHighlightjs();
if (data["result_text.text"]) { if (data["result_text.text"]) {
var $el = $form.find("textarea[name=result\\[result_text_attributes\\]\\[text\\]]"); var $el = $form.find("textarea[name=result\\[result_text_attributes\\]\\[text\\]]");
@ -76,4 +77,14 @@ function formAjaxResultText($form) {
} }
function initHighlightjs() {
if(hljs) {
$('.ql-editor pre').each(function(i, block) {
hljs.highlightBlock(block);
});
}
}
$(document).ready(function() {
initHighlightjs();
});
applyEditResultTextCallback(); applyEditResultTextCallback();