Wait till I come! » Blog Archive » Code tutorials for lazy people with Ajax Code Display
Random notes by Chris Heilmann

Code tutorials for lazy people with Ajax Code Display

Currently I am writing a lot of tutorials for an online self-training course about web standards and I ran into the annoyance of having to maintain example code in two places: the code itself and the HTML document with the explanations. Therefore I took jQuery and wrote a small script that automatically turns links to HTML code examples with HTML entities and line numbers. You can define which lines to display, which lines should be highlighted and you can add a live preview in an IFRAME when the link is clicked.

Technorati Tags: , , , , ,

7 Responses to “Code tutorials for lazy people with Ajax Code Display”

  1. Anup Says:

    Very nice. Out of curiosity, how come you used jQuery and not YUI?

  2. Michael Thompson Says:

    Very nice. Out of curiosity, how come you used jQuery and not YUI?

    Because jQuery is better…?

    I’d argue that you’d have less typing and faster development with jQuery, but as someone familiar with YUI, I’d love to hear the answer to this question.

  3. Chris Says:

    The reason was actually circumstances: I wrote this on my eeePC in Kate on Linux and I hadn't gotten the localhost to run yet. As jQuery's ajax works nicely with file:// and http:// I chose that.

    I also said in my talk at @mediaAjax that it doesn't matter what library you use unless you use one :)

    I disagree with faster development though. Once you wrote in jQuery for a long time it might be the case, but personally I am confused with all the chaining and anonymous functions. I try to know my scope in my scripts and actually hate "this" as it is never unambiguous.

    jQuery is a great piece of work, but I personally think it needs a lot of effort to write maintainable and clean code with it.

  4. Anup Says:

    Thanks for replying. It is interesting in that a major bit of work we are doing now, I am actually using both jQuery and YUI -- I have to admit I first found jQuery weird, but I really like it now.

    YUI is more like what I would normally expect to be writing so that was quick to get going with.

    The amount of time and code I have saved with jQuery though has really impressed me.

  5. Hosting Bookmarks Says:

    Hi,

    I hope those tutorial will be helpful and user friendly. One ready you can submit them to a special section I'd provide and they will reach targeted audience.

  6. Marc Says:

    I disagree with faster development though. Once you wrote in jQuery for a long time it might be the case, but personally I am confused with all the chaining and anonymous functions. I try to know my scope in my scripts and actually hate “this” as it is never unambiguous.

    I agree that chaining can be difficult to get used to, but it allows you to do so much more to be in a single line of code. You end up with expressive code that doesn’t rely on calling the object over and over again throughout the script to apply it’s properties/functions. If used wisely, each line of code defines an object’s actions and properties, without “scatterbraining” them throughout the script. That is only one, purely organizational benefit that I recognize every time I write a script. And the more I use jQuery, the more I realize that it has every bit of functionality that I need to get the job done.

  7. Jeff L Says:

    Awesome stuff...I can definitely see using this. Thanks.

Leave a Reply