googlearchive / code-prettify

An embeddable script that makes source-code snippets in HTML prettier.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Doesn't perfectly work when reload dynamically with javascript.

hash3liZer opened this issue · comments

I am trying to reload prettify.js file when an event occurs. The page doesn't reload, just a few parts of it. The file (prettify.js) gets load perfectly in the head tag. CSS (prettify.css) file too get successfully load up but nothing gets coloured. How am i trying to reload it:

$('script[src$="prettify.js"], link[href$="prettify.css"]').remove();

var head = document.getElementsByTagName('head')[0];
var prettify = document.createElement('script');
prettify.src = "..../prettify.js";
head.appendChild(prettify); 

Removing a <script> from the DOM doesn't undo the side-effects of its running.

commented

@maximMole seems like you're trying to prettify dynamically generated content, see this comment:
#268 (comment)

@amroamroamro tough not exactly what i was looking for but that's good. Now, i have to ran through all the pre block contents, prettify them and again put them into their places.