0

I am using Alex Gorbatchev's SyntaxHighlighter plugin to beautify XML messages. It works like a charm for small messages, but takes quite a bit of time for bigger ones (~10k lines) and the page gets frozen until the plugin finishes work. Now I would like to attach a load spinner to the syntaxhighlighter, so the "Loading.." message will be shown while the plugin does work and will go away once the plugin is finished. I already have the spinner, I just don't now how to hook it to the SyntaxHighlighter. All the information on load spinners I found was related to using them with Ajax calls. Going through the plugin's API did not help me either, I was looking for some kind of an event to signal completion, but since I am new to JS/jQuery I could easily miss it.

So my question is, how do I bind a load spinner with the SyntaxHighlighter plugin? Should I somehow use jQuery deferred object, or manually attach events to the plugin?

Any information will be highly appreciated.

Community
  • 1
  • 1
vasus
  • 23
  • 6

1 Answers1

1
<script type="text/javascript">
    SyntaxHighlighter.all();
    $(window).load(function () {
        $('#spinner').hide(); // Hide after load is completed
    });
</script>

Syntax Highlighter does not run at .ready but completes when .load() is completed. So by hiding your element (here id="spinner") when load is completed using jquery.

Took me a while to figure this out as well.