jquery load issue

后端 未结 2 1693
日久生厌
日久生厌 2020-12-09 23:30

I\'m loading pages asynchronously with the jQuery load function, like this:

tree.click(function() {
                if ($(this).hasClass(\"file\")) {
                


        
相关标签:
2条回答
  • 2020-12-09 23:50

    SyntaxHighlighter.all ties into the window.onload event - which only fires once.

    To syntax-highlight after the page loads, use the highlight function instead:

    content.load("content/"+this.id+".html", function () {
      // this is executed after the content is injected to the DOM
      contentContainer.effect("highlight");
      SyntaxHighlighter.highlight();
    });

    Fingers crossed that works, if not (based on looking at the code) you might need to chuck in some explicit arguments (where {} is an empty set of configuration parameters, and this will be content when called from the ajax load handler):

    
      SyntaxHighlighter.highlight({}, this);
    
    0 讨论(0)
  • 2020-12-10 00:03

    You need to call that in the callback to load:

      content.load("content/"+this.id+".html",function() {
         SyntaxHighlighter.all();
      });
    

    load is asynchronous so it happily continues along executing statements while the GET request is done in the background.

    0 讨论(0)
提交回复
热议问题