Drag and Drop Element Coordinates

Andrew:

If you're using draggable_element, you'll give it a name. For
instance, if you had a big grid, you could use this for every x and y
value.
<%= draggable_element "location_1_1", :revert => true %>

This would be the draggable_element:
<div id="location_1_1">Drag Me</div>

You can use the same element as a receiver that responds with an
action when a draggable_element is dropped onto it:
<%= drop_receiving_element "location_1_1", :url => { :action =>
"update_location", :new_x => 1, :new_y => 1} %>

Then you can handle assigning the dragged (new) to dropped spot (old).
  def update_location
    div, @oldrow, @oldslot = params[:id].split("_")
    @newrow, @newslot = params[:newrow], params[:newslot]
    @newloc = Location.find_by_row_and_slot(@newrow, @newslot)
    # do a page.redirect_to or page.update so show the updates we just
made
  end

I've used this for about a year and it's pretty handy.

Hope this helps! Let me know if you have any questions.

  -- Wes

Hmm, looking through my old code, I had two separate divs, one to drag
and one to receive.
So, that's the way I had it working. That said, I don't know if the a
single one doing both won't work, it's just not the way I did it
before.

  -- Wes