views:

31

answers:

1

Hi I'm using the syntax highlighter found here: http://code.google.com/p/syntaxhighlighter/

I have a page wherte it works fine:

<div id="codeArea">
  <pre class="brush:csharp">
       var customers = new Customer().GetCustomerList().AsEnumerable()
                                     .Where(c => c.CustomerID < 5);
  </pre>

However, I'm trying to load different snippets in using jQuery:

$("#sqoList").change(function () {
    var toLoad = $("#sqoList").val();
    $("#codeArea").load('/SQO/' + toLoad + "Example");

    //I tried running again after the load but still no joy.

    //SyntaxHighlighter.config.clipboardSwf = '../../Scripts/clipboard.swf';
    //SyntaxHighlighter.all();        
});

I noticed the first time the form is loaded in using Firebug That a lot of html is added to the 'codeArea' <div> after running the SyntaxHighighter.

This is not rendered when I load using jQuery.

Does anyone know how to force the extra html to render again?

Thanks

A: 

http://code.google.com/p/syntaxhighlighter/wiki/Usage

add a Name attribute to the pre tag

<pre name="code" class="brush:csharp">
       var customers = new Customer().GetCustomerList().AsEnumerable().Where(c =>  
       c.CustomerID < 5);
</pre>

and when in JS you write:

dp.SyntaxHighlighter.HighlightAll('code');

it gets transformed.

Alexander
Thanks - I still have no joy. name is not allowed undes XHTML-strict.Also, notice in my code I have no dp. prefix. When I add it in, I get dp is undefined - do you know why?I'm using shCore.js, shBrushCharp.js. Are these the correct files?
Ted
Yes, it seems that no `dp` is needed when loading the page.So when you call SyntaxHighlighter.all() after inserting the HTML with AJAX, it doesn't work?
Alexander
I have upgraded to version 3. Is that the vesion you are using?Anytime I try to use dp. i get an error and without it, no it doesn't work :(
Ted
where does the dp come from? - I can't find in any of the files.
Ted
I took `dp` from the documentation, although in my code it was not used. Have no idea what it's supposed to mean.
Alexander