Note that there are some explanatory texts on larger screens.

plurals
  1. POgoogle prettify not working in blocks called from jquery load
    text
    copied!<p>I'm a jquery beginner, and this question probably reflects that ignorance. I'm having a problem when I call Google Code Prettify from a local copy of Prettify (that is to say, I'm using </p> <pre><code>&lt;script type="text/javascript" src="localpath/prettify.js"&gt;&lt;/script&gt; </code></pre> <p>rather than </p> <pre><code>&lt;script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"&gt;&lt;/script&gt; </code></pre> <p>(in which case the problem goes away) in my html head tag. The problem is the following:</p> <p>If I put </p> <pre><code>&lt;pre class="prettyprint linenums"&gt; print "test1\n"; print "test2\n"; print "test3\n"; &lt;/pre&gt; </code></pre> <p>in the main html file, it works just fine. However, if I try to load a secondary html file into my main html file with jquery load, the prettfied code from the secondary html file isn't styled properly (the line numbers and keywords aren't shown). To be specific, I've put this in my in my html head tag:</p> <pre><code>&lt;script&gt; $(document).ready(function() { $('#my_element').load('my_element.html'); prettyPrint(); }); &lt;/script&gt; </code></pre> <p>and my_element.html has the exact same code block as worked in the main html file:</p> <pre><code>&lt;pre class="prettyprint linenums"&gt; print "test1\n"; print "test2\n"; print "test3\n"; &lt;/pre&gt; </code></pre> <p>it gets loaded into the div tag of id == "my_element"; however, it's not styled properly on the main page. why?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload