20 June 2007

Programmatic GreekingWidget for dojo

When playing with dojo's fancy container and layout widgets, it is nice to be able to greek quickly. Pasting a bunch of generated lorem ipsum text gets old quickly, so here's a programmatic, custom dojo widget that'll generate as much or as little placeholder text as you need. The JavaScript source code uses the dojo 0.4.x APIs. Please feel free to use and improve this widget however you like. Here's an HTML snippet that demonstrates the widget's usage...

        <title>Usage and unit tests for GreekingWidget</title>

        <script type="text/javascript">
            djConfig = { isDebug: true };

        <!-- Be sure to point to your local dojo installation -->
        <script type="text/javascript" src="dojo-0.4.3-widget/dojo.js"></script>

        <!-- Be sure to point to where you save the source code -->
        <script type="text/javascript" src="GreekingWidget.js"></script>

        <style type="text/css">
            .FooBarClass {
                color: red;
        <h2>Usage and unit tests for GreekingWidget</h2>

        <h3>Default options</h3>
        <div dojoType="GreekingWidget"></div>

        <h3>One sentence</h3>
        <div dojoType="GreekingWidget"

        <h3>Generate blockquotes</h3>
        <div dojoType="GreekingWidget" 

        <h3>Add CSS class to make them red</h3>
        <div dojoType="GreekingWidget" 

        <h3>Add CSS style to make them tiny</h3>
        <div dojoType="GreekingWidget" 

And here's the test page output...

12 June 2007

The joys of JavaScript error messages

Today I meant to type

but instead I typed
with the incorrect extra period.

Firefox kicked back the amazingly helpful

XML descendants internal method called on incompatible Object
which I stared at dumbfounded. All of Firebug's glorious power was seemingly useless against this error. It didn't help that I was working atop a custom Dojo build.

Then I flipped back to my editor which thankfully still had the cursor next to the extra period. A simple backspace and I was moving again...

Subscribe Subscribe to The Return of Agent Zlerich