[Rails-spinoffs] Re: Sortable table rows instead of list items?

WJRANKIN at UP.COM WJRANKIN at UP.COM
Thu Jun 8 19:43:01 GMT 2006


Thanks Eric,

Your reploy prompted me to look a little closer at the existing docs at
this URL:
http://wiki.script.aculo.us/scriptaculous/show/Sortable.create

There's a note to the effect that it can be made to work using TBODY as the
container and TRs as the sortable. It seems to be working, at least in this
simple example:

<table width="100%" class="separatedSM">
<tbody id="firstlist">
      <tr class="RowOne">
            <td>Row 1</td>
      </tr>
      <tr class="RowTwo">
            <td>Row 2</td>
      </tr>
      <tr class="RowOne">
            <td>Row 3</td>
      </tr>
      <tr class="RowTwo">
            <td>Row 4</td>
      </tr>
</tbody>
</table>

 <script type="text/javascript">
 // <![CDATA[
   Sortable.create("firstlist",
     {tag: "TR", dropOnEmpty:true, containment: ["firstlist"], constraint:
false});
 // ]]>
 </script>

Jeff Rankin
Human Factors
544-4333


                                                                                                                                        
                      Eric Anderson <eric at afaik.us>                                                                                     
                      Sent by:                                 To:       rails-spinoffs at lists.rubyonrails.org                           
                      rails-spinoffs-bounces at lists.ruby        cc:       (bcc: William J. Rankin/UPC)                                   
                      onrails.org                              Subject:  [Rails-spinoffs] Re: Sortable table rows instead of list       
                                                                items?                                                                  
                                                                                                                                        
                      06/08/2006 02:17 PM                                                                                               
                      Please respond to rails-spinoffs                                                                                  
                                                                                                                                        
                                                                                                                                        




WJRANKIN at UP.COM wrote:
> Hi, I'm wondering if it's possible to create a table with sortable rows.
[...snipped details...]
>  <script type="text/javascript">
>  // <![CDATA[
>    Sortable.create("firstlist",
>      {dropOnEmpty:true,containment:["firstlist"],constraint:false});
>  // ]]>
>  </script>

You can sort with other items besides a list but you must specify the
tag of the items to be made sortable if you do. This is the "tag" option
and should probably be set to "tr".

That being said I believe there are browser issues with sorting tables
(I think specific to IE) so even with proper arguments it is not really
sortable (but other elements are and if you really wanted a
cross-browser table you could simulate it with <div> tags or something).

Eric

_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs at lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs





More information about the Rails-spinoffs mailing list