by Peter Higgins

I like widgets you can create in bulk, from valid markup. Quickly, I’m going to show you how to use query() and dojo.dnd.Moveable to create a set of dragable “magnets” on the screen.

Start with some basic CSS:

span.magnet {
    border:2px solid #ccc;

and in your HTML, several span’s class:

<div id="holder">
    <span>One</span> <span>Two</span> <span>Three</span>

Then, in script, we find and convert those spans to dragable objects:

// require dojo.dnd stuff:
// page ready
    // get every "span" in node id="holder"
          // add "magnet" class
         // make each node moveable:
               new dojo.dnd.Moveable(node);

And all of the rest of the work should be done for you. You should have three dragable nodes:

One Two Three

Tags: , ,

This entry was posted on Friday, February 22nd, 2008 at 2:34 pm and is filed under Dojo Cookies. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

You must be logged in to post a comment.