I have a page on my website that I am making a call to using a jQuery ajax call. It loads in a div. But whenever I the page is loaded, it loses the snytax highlighting that it should be displaying. Ex:
<html>
<head>
<!-- syntax highlighting script -->
<script type="text/javascript" src="syntaxhighlighter.js"></script>
</head>
<body>
<!-- div that displays ajax page cal -->
<div id="awesomeo">
</div>
</body>
</html>
It works on the initial page load if I have something in awesomeo
but if a page is loaded via AJAX into the div, the syntax disappears.
EDIT: The following is the code that is in the header:
<script type="text/javascript" src="/scripts/shCore.js"></script>
<script type="text/javascript" src="/scripts/shBrushBash.js"></script>
<script type="text/javascript" src="/scripts/shBrushCpp.js"></script>
<script type="text/javascript" src="/scripts/shBrushCSharp.js"></script>
<script type="text/javascript" src="/scripts/shBrushCss.js"></script>
<script type="text/javascript" src="/scripts/shBrushJava.js"></script>
<script type="text/javascript" src="/scripts/shBrushJScript.js"></script>
<script type="text/javascript" src="/scripts/shBrushPhp.js"></script>
<script type="text/javascript" src="/scripts/shBrushPlain.js"></script>
<link type="text/css" rel="stylesheet" href="/styles/shCore.css"/>
<link type="text/css" rel="stylesheet" href="/styles/shThemeDefault.css"/>
<script type="text/javascript">
SyntaxHighlighter.config.clipboardSwf = '/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>
This is from: http://alexgorbatchev.com/wiki/SyntaxHighlighter That is all that is used for syntax highlighting... Suggestions?
Figured it out: Adding
<script type="text/javascript">
SyntaxHighlighter.highlight();
</script>
on the page being called works.
your syntaxhighlighter probably has a function bound to document.onload. You'll need to find that function and call it again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With