An Atlas Challenge!
Okay, I've had enough, I officially challenge the Atlas community to solve my simple problem! Here is my situation: I'm working on an ASP.NET project where I have a bunch of dragging and dropping of DOM elements. I want a script library that will make dragging and dropping easy. I've looked into the Atlas stuff and for the most part I like what I see. However, it seems to fall apart when I'm not using their pre-built components. I can't seem to get what I consider the "simplest" of examples to work.
So here is an example, its taken from Thomas Fuchs
script.aculo.us web site and uses that library.
There are two images that can be dragged, and when they are dropped they go back
to where they came from. If an image is dropped on a specific <div>
element then I can execute some code to handle the event.
Here is some sample code:
<img id="product_1" class="products" src="images/product-1" alt="mug">
<img id="product_2" class="products" src="images/product-2" alt="t-shirt">
<div id="shopping_cart" class="cart">
<img src="images/drag-here" alt="">
<div id="shopping_cart_text">Drag all the stuff you ever want right here.</div>
</div>
<script type="text/javascript" language="javascript" charset="utf-8">
new Draggable('product_1',{revert:true});
new Draggable('product_2',{revert:true});
Droppables.add('shopping_cart', {
accept: 'products',
hoverclass: 'drophover',
onDrop: function(element) {
$('shopping_cart_text').innerHTML =
'Dropped the ' + element.alt + ' on me.'; }});
</script>
I think that all modern AJAX-ish libraries should make implementing this simple and easy. Can anyone show me a simple and easy way to do this in Atlas? From what I've read the "Atlas way" is to write my own controls implementing IDragSource and IDropTarget to do this. Am I wrong? Is there an easier way? If so, can someone please show me?
This started with a comment conversation I had with Bertrand Le Roy today on his blog. (Be sure to check out my use of a double negative in the comment thread. <sarcasm>Oh yeah, that's some good writing!</sarcasm>) Hopefully the conversation won't end here.
Oh, and why not just continue with the Prototype/script.aculo.us combination? It works right? Yeah, it works, and it works really well. If Atlas is a dog and just won't work I won't have a problem releasing using that library. And while I'm all for inserting all things Ruby and Rails at work; the right thing for the long-term success of this project is to have a consistent platform. There are other areas of this project where dropping an Atlas component is the easiest, the best, and the right thing to do. Beyond the concerns about prototype mixing well with other JavaScript libraries, how great would it be for future developers to get all the info they need to support this app from a single book they pick up at any book store?