mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-12 08:04:34 +08:00
reinitialize highlight.js after ajax call
This commit is contained in:
parent
62e4d32221
commit
897e34a23b
2 changed files with 22 additions and 1 deletions
|
@ -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 () {
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue