On Jul 6, 8:25 pm, PROM <[EMAIL PROTECTED]> wrote:
> Hi, I'm new around and I have been trying to achieve a certain effect
> using script.aculo.us, but it seems I can't handle it alone due to the
> fact that I've never used prototype before. I can't even say that I'm
> a good javascript coder ... so I'd highly appreciate any help
>
Welcome. It does take some getting used to!
Note that there is a brand-new google group
http://groups.google.com/group/prototype-scriptaculous
for prototype and script.aculo.us. Existing queries like yours will
get answered here for the moment, but people are encouraged to post
them to the new group.
> Here is my problem: I have a list of draggable divs, variable number
> of them. I also have a fixed number of droppables. I want the user to
> be able to distribute a specified amount (less than the number of
> droppables) of the draggables into droppables of his choise (only one
> draggable per droppable). Nothing difficult so far (except that I
> don't know how to limit the user to place only one draggable into a
> droppable, but that would not be a problem if the following
> functionality could be implemented).
> Now what I could not make by my own is: While the user makes the
> distribution of the draggables he may decide that he wants to place a
> draggable in a non-empty droppable. I want him to be able to do that -
> and when he drops it into the full droppable the one that is in the
> droppable should return either back to it's original place as it was
> dropped to a non-droppable area or go to the droppable (no claims to
> be moving to there, just appearing there is enough) from which the
> other droppable was dragged (if it was not dragged form its original
> place but from another droppable).
>
All that script.aculo.us gives you is the code to do the drop. Your
own 'onDrop' function must do this.
If you want to return it to where the dragged element came from, you
can get that from the dragged element: something like
function onDrop(dragged, dropsite, event)
{
...
var origin = dragged.up('...')
where you give some suitable selector in the 'up' - for example if you
gave all your containers class 'container', it would be
"dragged.up('.container')".
If you want to return the bumped element to where IT originally came
from, you will have to remember that information yourself somehow -
perhaps in a Javascript hash, or setting a custom attribute in the
element; and then retrieve that origin when you want to send it back.
I don't think there's a 'move' function provided in script.aculo.us -
you could look at the source code for Draggables and see how it does
the 'revert'.
Colin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to rubyonrails-spinoffs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---