I am not sure how many of you are using draggables/droppables but I thought I would do some experimentation and try and learn how to use them on my own. Well, I have draggables, and I have droppables. I do have one question for now. The droppable onDrop event seems to pass in 2 objects, the dropped object, and the container the object was dropped on. My question is this, can I figure out the container the dropped object came from? For example: 1 draggable (id: myDraggable) 2 divs (ids: myDropA, myDropB) which are both droppables accepting the draggable myDraggable starts as a child of myDropA I move myDraggable from myDropA to myDropB At this point in the myDropB onDrop, I want to know about myDropA, myDropB and myDraggable. Currently I think I can only see myDropB, and myDraggable Feel free to ask questions if this makes no sense. It is after all my first script.aculo.us drag/drop thingy-ma-bob. -Greg
When you define you draggable object, assign a member variable to it that stores info about the parent... var myDraggable = new Draggable(...); myDraggable.parentDiv = $(''myDropA''); Then when it gets dropped, you can see where it came from simply by accessing the parentDiv property. Expandos are your friend. The information transmitted in this electronic mail is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers.
Nevermind... For some reason I always miss the obvious. I needed element.parentNode.id as in: Droppables.add(''myDropB'', { accept:''draggable'', onDrop:function(element, dropped){ alert (element.parentNode.id); } } ); On Mar 29, 2006, at 3:24 PM, Greg Militello wrote:> I am not sure how many of you are using draggables/droppables but I > thought I would do some experimentation and try and learn how to > use them on my own. > > Well, I have draggables, and I have droppables. > > I do have one question for now. > > The droppable onDrop event seems to pass in 2 objects, the dropped > object, and the container the object was dropped on. My question > is this, can I figure out the container the dropped object came from? > > For example: > 1 draggable (id: myDraggable) > 2 divs (ids: myDropA, myDropB) which are both droppables accepting > the draggable > myDraggable starts as a child of myDropA > I move myDraggable from myDropA to myDropB > At this point in the myDropB onDrop, I want to know about myDropA, > myDropB and myDraggable. Currently I think I can only see myDropB, > and myDraggable > > > Feel free to ask questions if this makes no sense. It is after > all my first script.aculo.us drag/drop thingy-ma-bob. > > > -Greg > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Using parentNode will only work when your draggable is a direct descendant of the container... that will fail you as soon as you try any layout more complicated than that (nested containers, tables, etc...) The information transmitted in this electronic mail is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers.