WJRANKIN-J6ISH/MDR2c@public.gmane.org
2006-Jun-08 18:54 UTC
Sortable table rows instead of list items?
Hi, I''m wondering if it''s possible to create a table with sortable rows. Here''s what I''ve started with, but it isn''t working: <table width="100%" class="separatedSM" 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> </table> <script type="text/javascript"> // <![CDATA[ Sortable.create("firstlist", {dropOnEmpty:true,containment:["firstlist"],constraint:false}); // ]]> </script> Is the template header, I''m sourcing prototype.js, scriptaculous.js, and dragdrop.js. Currently, nothing is draggable. I created a test UL and made it sortable, and it worked fine. Does the sortable functionality only work with un/ordered lists? TIA, Jeff Rankin Human Factors 544-4333
WJRANKIN-J6ISH/MDR2c@public.gmane.org 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
WJRANKIN-J6ISH/MDR2c@public.gmane.org
2006-Jun-08 19:43 UTC
Re: Re: Sortable table rows instead of list items?
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-ANzg6odk14w@public.gmane.org> Sent by: To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org rails-spinoffs-bounces-1W37MKcQCpIbvKGg9ot7NQ@public.gmane.org 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-J6ISH/MDR2c@public.gmane.org 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-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs