Dojo 1.6 Parser Confusion: What’s in a Widget, Anyway?

May 20, 2011 by Ken · 2 Comments 

Dojo 1.6 introduces a new alternative declarative markup syntax using HTML5 data attributes, with the aim of allowing definition of object instances via HTML without forcing users to write invalid markup. The new syntax primarily revolves around the use of data-dojo-type in lieu of dojoType, and a data-dojo-props attribute to hold any properties to be passed to the constructor’s first argument.

However, this new syntax brings with it some significant differences in behavior, which has caught many users off-guard. For instance, you might try something like this:

<input data-dojo-type="dijit.form.ValidationTextBox"
    id="tb_username" data-dojo-props="required: true"
    style="width: 300px;" name="username" value="bob"/>

You would be surprised, then, to observe that the widget appears to ignore your style, name, and value settings altogether. What gives? Let’s find out.

Read more

Making a Smarter TabContainer

June 25, 2010 by Ken · 4 Comments 

I’m sure this one has been asked numerous times, but it came up most recently on IRC from darkschneider (with an additional nod from ttrenka). The dijit.layout.TabContainer widget is tremendously useful, but it has a noticeable shortcoming that, while minor and innocuous, can still be irritating: if you’ve navigated between tabs and then close the current one, it always sends you back to the first tab in the container, rather than the previously active tab.

This is something I had noticed while working with Dojo on a mockup at my job over a year ago, and I developed a solution to it then. Now that I’ve got this blog here, I might as well share it for others’ benefit.

UPDATED on 6/28 to bring the example more in line with how TabContainer works in Dojo 1.4+

Read more