Working with YUI’s Drag and Drop Utility
Just for the heck of it, I’ve been messing around with YUI’s Drag and Drop utility. In the past, over on Phondoo, I’d used Dojo’s Drag and Drop implementation, so it took a little bit of work to get used to the YUI way of doing things.
The essential difference in the two is that Dojo’s implementation is more widget-y (if that’s a word) while YUI’s implementation is more customizable. Dojo Drag and Drop more or less works out of the box; with the YUI version, you’ll have to write a bit more custom code to achieve the out-of-the-box Dojo effects. However, because it’s so customizable, you’ll be able to really turn it into an application with a look-and-feel that’s all your own.
Because bulleted lists improve readibility, here’s pretty much exactly what I just said, all bulleted out for scanability:
- Dojo’s widget-ness– Without any customization, you’ll be able to do a lot more with Dojo’s Drag and Drop. Basically, Dojo’s provided a fill-in-the-blanks kind of implementation, where you create a couple objects, and bang! it all works. With YUI, you’ll need to write more code.
- YUI is more customizable– YUI’s Drag and Drop API has a lot more exposed, especially in regards to event bubbling: you’ll be able to access more points in time during an interaction cycle with YUI.
- YUI has a more open API– You have a lot more access with the YUI drag and drop API. Event bubbling aside, you can more easily customize (or choose not to implement) pieces of the Drag and Drop cycle, which leads to code that fits your situation better.
Which works better? Well, if you’d like to get up and running right away, Dojo’s widget-y implementation is your choice. If you’re not afraid to write some code, YUI will give you a more robust, customized solution. In all, once you’ve gotten used to (and learned to enjoy and take advantage of) YUI’s event bubbling you’ll find that these hooks can make all the difference in your application (they provide many more opportunities to have your code do something when it needs to be done). Both implementations are very nice, work very well, and, although I’d give YUI the edge, come recommended.
technorati tags:yui, dojo, draganddrop, javascript, dhtml