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

Writing Custom Save Logic for ItemFileWriteStore

June 22, 2010 by Ken · 5 Comments 

This post focuses on a question reincarnated most recently by cbarrett1 in the Dojo IRC channel:

  • How do I implement custom save logic on an ItemFileWriteStore?

This was always something I wanted to become familiar with, and upon initial inspection it seemed easy enough to implement an example. It’s also a prime opportunity to put across a few other general points as well. While the main intent of this post should be clear, it also briefly touches upon various other topics along the way, so hopefully there’s a little something for everybody who’s learning Dojo.

Read more

ComboBox vs. FilteringSelect: Selecting The Right Tool for the Job

June 13, 2010 by Ken · 3 Comments 

Continuing for the moment on the topic of Dijit, I turn my focus to two dijit.form widgets which are easily confused: ComboBox and FilteringSelect. These widgets are very similar in appearance, but differ fundamentally in behavior and functionality, which can easily lead to confusion if one is not fully aware of what sets the two apart.

This post aims to give a synopsis of what sets these widgets apart from each other, and will also address a question that I’ve seen repeatedly in the #dojo IRC channel:

  • “How do I get the value of the selected option in a dijit.form.ComboBox?”

    Read more

Of Dijits and DOM nodes

June 5, 2010 by Ken · 2 Comments 

This shall be the first of an unpredictable number of posts wherein I discuss recurring sources of confusion for newcomers to the Dojo Toolkit.  I’ll be tagging such posts dojofaq, for future reference.

One of the main attractions to the Dojo Toolkit is Dijit, a library of skinnable widgets built upon the functionality available in dojo core (Dijit = Dojo + widget).  However, diving head-first into Dijit without a primer can quickly lead to various common points of confusion, which I’ve seen come up repeatedly in the IRC channel.  This article aims to cover a bit of the basics, demystifying and addressing questions such as the following:

  • “Why doesn’t dojo.byId('mywidgetid').attr('value') or dojo.attr('mywidgetid', 'value') do what I expect?”
  • “I dojo.destroyed my widget, but when I recreate it it tells me the id is already registered!”
  • “I’m connecting to my widget’s onclick but it’s not firing!”

These questions all have a common source – the confusion between working with Dijit widgets, versus working simply with DOM nodes. Read more