Alain Ravet
2006-Feb-17 12:12 UTC
Sortable list: how to create a triggering "handle"/deactivate part of the <li> element?
Hi all, When using sortable lists, a click anywhere in a <li> element will trigger the "sort_by_dragging" mode, and have the clicked element follow the mouse. The active area is the entire <li> element. Is there a way to either : - limit the active/triggering "area" to a part of the <li> element (like a luggage handle) or - prevent a part of the <li> element from triggering the sort mode ? Context (one of many examples where it''s needed): I''m merging many screens - sort, edit, delete - into one => each <li> element is made of 1 text 2 list of tags where each tag is a link 3 icon + link to an action: "edit tags" ... Problem: a click on "Edit tag" opens/show a small form under the element, but at the same times it triggers the sort mode => the entire line follows the mouse when I try to place the focus in the form. Alain
Danger Stevens
2006-Feb-17 17:31 UTC
Re: Sortable list: how to create a triggering "handle"/deactivate part of the <li> element?
> Is there a way to either : > - limit the active/triggering "area" to a part of the <li> element > (like a luggage handle) > or > - prevent a part of the <li> element from triggering the sort mode > ?There''s a great example of how this is done at the wiki: http://wiki.script.aculo.us/scriptaculous/show/SortableListsDemo One of the options you can pass to the Sortable is what classnames to recognize as a handle. If a tag with the classname specified appears within the Sortable object, that class'' contents will be used as a handle. So, for your project: <ul class="sort" id="list"> <li id="1"> <span class="handle">grab</span> <span class="edit">edit link</span> text </li> <li id="2"> <span class="handle">grab</span> <span class="edit">edit link</span> text </li> </ul> and then: Sortable.create("list", {handle:''handle''}); - Danger _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Alain Ravet
2006-Feb-17 17:50 UTC
Re: Sortable list: how to create a triggering "handle"/deactivate part of the <li> element?
Thanks Stevens> There''s a great example of how this is done at the wiki: > http://wiki.script.aculo.us/scriptaculous/show/SortableListsDemoSo, in Rails View: ------- part 1: <ul> <li> <span class="my_handle">****</span> <<<--------- HERE more stuff here that cannot be used as dragging handle </li> ... </ul> part 2: <%= sortable_element ''sortable_list'', :handle => "my_handle" , <<< ---------------- AND HERE ... %>