Dork detour to Dojo

Back in the early days of the web, we asked the web to do pretty simple things such as receive submitted form data, and the Javascript whatsits and whosits were iffy and not cross browser. The early Javascript language (or ECMAScript, if you want to be a purist) was lame. To top it off, a lot of browsers in those days didn’t even support it. Oh, and did I mention the debugging tools were nonexistent. I remember debugging my early javascripts by commenting out most of it, then moving the comments down until I could see where it died. Oh yes there was hair tearing.

Then enter Ajax, and more importantly, Google, building major map gizmos in Ajax (which relies on Javascript.) And suddenly Javascript was legitimate. Now thanks to Ajax we can have controls and widgets on web apps just like a desktop app, and the curmudgeons who fail to enable it are doomed to a rather dull experience. By their reasoning I’d be safer if I never left my house, but dang it, you can’t cut yourself off from the world just because something might happen.

Enter Dojo. Dojo is a javascript/css library that you can use to ease the task of making nice Web 2.0-ish user interfaces. It is employed heavily by Ning, and they just made a deal to be bundled as part Zend Framework, so I thought I’d better be conversant with it. I always hated writing UI code by hand because it was soooo fiddly. People did some amazing things with Javascript but it always required a tremendous reverse engineering effort to figure out how they did it, or even if they provided libraries it was almost always particular code that needed customization anyway. My hope is that Dojo has encapsulated a lot of these issues and gives me useful routines I can just USE. Look at the heavy hitters who are betting on it. Of course there’s always the learning curve. Still it’s easier than the back end, in many ways.

Installation should not be difficult. Nah you just copy it, pretty much anywhere. It even comes with an extensive test harness. I was a little concerned that several tests failed but I forged on and everything I tried seemed to work.

Tutorial There is a very nice step by step third party tutorial at sitepenlabs. I wish Ning had a tutorial like this. And Dojo itself has an extensive online manual. I’m seeing a parallel between the chained queries in Dojo and the ones in Ning. I was able to make a DOM element change its innerHTML on click so whatever tests I failed they didn’t break it that bad. Setting innerHTML is simple enough that you can do it quite easily without all this rigamarole, but I’m expecting something around the corner where it really makes sense to use the package.
And there it is: the ability to chain events. That’s always an issue when you’re writing directly in javascript. When you want an event to trigger more than one thing you end up with all these little onesie functions. No more. Now you’ll have a bunch of custom chains instead. I guess the advantage is that it makes it explicit by context what’s going on. And then you move to the cool eye candy of animations. I didn’t quite grok all the ins and outs of animation the first time through but when I’m task driven I’m sure it will all make sense. I wanted to move to Ajax. Unfortunately the Ajax is still fairly verbose, but it seems to be better than the library I have used in the past at keeping stuff together. It’s nice and explicit that you have to do a preventDefault on a submit. In the past you had to remember to return false from whatever ajax leaning script you were calling.

Comments are closed.

A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.