Use Syntax Highlighter on AJAX loaded content

前端 未结 3 780
遇见更好的自我
遇见更好的自我 2020-12-30 01:48

How can I use Alex Gorbatchev`s Syntax Highlighter on content loaded after \'window\' emits \'load\' event? I am trying this way:

    $.ajax({
        url:           


        
3条回答
  •  無奈伤痛
    2020-12-30 02:09

    I`ve found the answer to my question in one of his examples:

        $.ajax({
            url:    file,
            success: function(code) {
                $('.fileName').text(file);
                var brush = new SyntaxHighlighter.brushes.JScript(),
                    html;
                brush.init({ toolbar: false });
                html = brush.getHtml(code);
                document.getElementById('source').innerHTML = html; 
            }
        });
    

提交回复
热议问题