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();
applyCollapseLinkCallBack();
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() {
Comments.initialize();
Comments.initCommentOptions("ul.content-comments");
@ -568,6 +577,7 @@ $(document).ready(function() {
expandAllSteps();
setupAssetsLoading();
initStepsComments();
initHighlightjs();
$(function () {

View file

@ -61,11 +61,12 @@ function formAjaxResultText($form) {
applyCollapseLinkCallBack();
toggleResultEditButtons(true);
expandResult(newResult);
initHighlightjs();
});
$form.on("ajax:error", function(e, xhr, status, error) {
var data = xhr.responseJSON;
$form.renderFormErrors("result", data);
initHighlightjs();
if (data["result_text.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();