Now I am working day in day out with dojo, finally I got myself to working with it.
Well, the first day I took all this for real and hoped to build applications in less time using the powerful, portable, lightweight, and tested tools. I’ve learned two things: 1) don’t believe everything and 2) head up.
My first task was to create a simple slider. Since there is no slider widget yet I want to build my own slider and may be make it a widget later. For creating a slider it’s logical to use dojo’s drag’n'drop capabilities. I have created a simple span, which contains the handle that you move relative to the outer span. The offset will be used to determine the slider’s value. Sounds pretty easy.
So I downloaded version 0.2.2, the latest version. I used the manual example and got the span to drag quite quickly. Cool. So now I need to catch the onDragEnd event, which gets called when I stop dragging and at this time I will get the drag offset. There my problems started. After almost one day of investigation and unsuccessful asking for help on the irc channel #dojo, I found a post on the mailing list that told me that I need to use the latest svn head version. The 0.2.2 has a bug which doesn’t let the onDragEnd event work. Ok, at least some kind of success.
So I looked up in the manual on how to check out from the dojo svn. Darn, I just couldn’t get the source checked out. I was already feeling quite stupid about asking so much stuff on the irc channel, so I switched to only searching the mailing lists and finding out myself. Fortunately I had subscribed to the dojo list already quite a while ago, so I could nicely search it (I hate those online archives, they are always so unusable). Soon I found the post I was looking for. The svn has moved and the manual had not been updated yet. I just made sure to try it first before posting on #dojo. Yeap, that works. And the manual got updated right away too. Nice. And the onDragEnd works too. Finally.
Next thing on my list was to get the drag offset by which my slider was moved. Since I had been diving into the source code quite often until now I knew that there is a dragOffset property, that I surely just need to read out. Nothing easier than that, I thought. So I just had to look which of the objects has this property and how I can access it. Mmmh, the DragObject has this property. But the event object that gets passed to my method I call upon onDragEnd does not contain any reference to the DragObject. So I don’t really know how to read out the dragOffset, that is stored in there. Oh man, this seems like some work ahead. Huhu, I found this in the source code.
// FIXME: we need to add dragSources and dragObjects to e
Ok, I think I know what it means, this code here is still pretty much untested, incomplete and in beta, if not alpha state. Obviously noone ever needed to access the data I want to read out, even though it seems a basic thing to do. Ok, I think I need to dive a bit deeper into all this and fix the stuff needed to make it run and get my widget up.
Why not give up and use another
Dojo seems to be on the right way. I think this is the
framework toolkit that does it right. It is just the same thing that I would write, in fact I had started just exactly the same thing a while ago but never even got close to where dojo is now. As sophisticated and well thought through as dojo seems, I think it has a shiny future.
The browser stuff is abstracted for DOM, events, drag’n'drop and all the other nice things. The widget system seems really clever and promising. I just hope the mistake of only allowing one widget of each type will not be made (like PEAR did).
framework toolkit that you can hardly oversee when evaluating the market.
I’ll stick to dojo and may be I will even try to help out. Good stuff! Congratulations guys!
[Update] After reading some of the dojo.book, I had to replace all the frameworks by toolkits. Even though I think this distinction is irrelevant, but anyway.