dojo - good clean fun

I played around with dojo a bit tonight, doing some work to prepare a demo for tomorrow (holy crap, it nearly IS tomorrow). I’m only using the drag and drop stuff at the moment, but I have to say, it’s awesome. With very few lines of code, I was able to set up drag sources (the things you pick up and move around) and drop targets (the things you drop other things onto). Override the drop handler and voila! Instant DND implementation handled in roughly 8-10 lines of code.

var drag = new dojo.dnd.HtmlDragSource(dojo.byId(”dragid”), “thing”);

var drop = new dojo.dnd.HtmlDropTarget(dojo.byId(”dropid”), ["thing"]);

drop.onDrop = customDropHandler;

That’s pretty much it. The first line makes something draggable. You pick the thing to drag by its ID. The “thing” can be whatever you want to call it. It’s sort of a drop classification. You use that in the second line when creating the drop target. The drop target is also picked by its ID. Again you see “thing” show up. This means that the drop target will accept any draggable in that classification. That allows you to have drop targets that only accept certain draggables on the page, in case you have a bunch of different drag types.

Dojo is pretty much just what the doctor ordered for people like me. People who know their way around JavaScript well enough to make something happen, but who aren’t adept enough to make it do anything flashy on their own.

Update: The complete lack of documentation and sample code for the majority of dojo is a major turnoff. While I was able to stumble my way through drag and drop, using the widgets has been a disaster. The demo seems to work fine and I try to duplicate what it’s doing. But no matter what, I just can’t get the widgets to do anything.

3 Responses to “dojo - good clean fun”

  1. lars Says:

    Are you going to post your demo?

  2. Ryan Says:

    Sadly, no. It’s to demo some internal stuff. I will probably use dojo to build something in my spare time, though.

  3. Lars Says:

    “We are men of action, lies do not become us.”
    - Westley, The Princess Bride

Leave a Reply