# Scriptaculous, snap draggable to droppable or revert

**URL:** <https://www.ruby-forum.com/t/scriptaculous-snap-draggable-to-droppable-or-revert/187946>\
**Category:** Rails\
**Created:** [May 3, 2010, 3:28am UTC](https://www.ruby-forum.com/t/scriptaculous-snap-draggable-to-droppable-or-revert/187946 "2010-05-03T03:28:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![inertia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/d07c76/32.png) [@inertia](https://www.ruby-forum.com/u/inertia)\
**Post date:** [May 3, 2010, 3:28am UTC](https://www.ruby-forum.com/t/scriptaculous-snap-draggable-to-droppable-or-revert/187946/1 "2010-05-03T03:28:20Z")

</div>

Hello community,

I am a fairly new RoR programmer and I need some help with Scriptaculous  
Drag and Drop:

So I have

\<%= draggable\_element(@div\_id, :revert =\> “failure”, :snap =\> 5) -%\>

and a droppable:

\<%= drop\_receiving\_element(@team\_div\_id, :with =\> “‘player=’ +  
(element.id)+ ‘&position=’ + #{draft\_position}” ,:complete =\>  
visual\_effect(:highlight), :update=\>“status” , :url =\> { :action =\>  
“receive\_drop”}, :hoverclass =\> ‘hover’ ) %\>  
\<% end %\>

I would like to allow the draggable to “snap” to a droppable position if  
close or revert back to its original position if it isnt near a  
droppable.

I have searched over the net but I have been unsuccessful with this  
issue. I understand there’s the Snap option but I want it to snap INTO a  
droppable when close or go back to its original position.

I have found some example code such as:

But how do I translate that using drop\_receiving\_element?

Can anyone help me with this, or point me in the right position?  
Essentially its just “Snap to a grid” but I have been unable to find a  
simple example. I appreciate the help!
