views:

190

answers:

1

I have a rails project where the the view displays a list of items. I use acts_as_list to make the list DnD orderable and in_place_editing on each item to, well, edit it.

My problem is that when I DnD the items around, the item I drag automagically becomes editable when I drop it. Any tips on how I can avoid that behavior.

Ideally, I'd like to make it editable by clicking a small icon next to the item, but I don't know how to make that work with this plugin.

Thanks in advance.

+2  A: 

This happens because the element you are dragging has a listener on mouseup that begins the edit. You can specify an :external_control in the options hash if you want a different element to trigger the edit.

<div id="<%= dom_id(@obj) -%>">
  <span><%= @obj.to_s -%></span>
  <img id="<%= dom_id(@obj, :edit) -%>" src="edit_handle.png"/>
</div>
<%= in_place_editor(dom_id(@obj), :external_control => dom_id(@obj, :edit)) %>
<%= draggable_element(dom_id(@obj)) %>
Sam C
That seems to only be part of it. Adding the :external_control makes another element trigger it along with clicking the actual text. Is it supposed to disable the effect of clicking the original text to make it editable?
CJ