Not my code,  Christian Bach is the father of that code. But I used it
for a cool little sortable table!

On 10/12/06, Adrian Sweeney <[EMAIL PROTECTED]> wrote:
> Have you already written this?
>
> On Thu, 2006-10-12 at 16:16 -0700, Ⓙⓐⓚⓔ wrote:
> > this is a helluva plugin... totally without html additions, and the
> > magic just happens!
> > /*
> >  *
> >  * TableSorter - Client-side table sorting with ease!
> >  *
> >  * Copyright (c) 2006 Christian Bach (http://motherrussia.polyester.se)
> >  * Licensed under the MIT License:
> >  * http://www.opensource.org/licenses/mit-license.php
> >  *
> >  * $Date: 2006-08-21 14:43:23 +0000 (må, 21 aug 2006) $
> >  * $Author: Christian $
> >  *
> >  */
> >
> >
> > On 10/12/06, Adrian Sweeney <[EMAIL PROTECTED]> wrote:
> > > Hi guys today I finally got around to using jQuery today and man do i
> > > love it.  wished that I had known about it before I started my last
> > > project. would have saved me a couple of months work.
> > >
> > >
> > > Ok well back to today
> > >
> > > I needed to take a structure (table made of div's) and sort by
> > > alphabetic order once I got my head around the way that jQuery worked my
> > > boss who had used jQuery more showed me the exact code I needed for
> > > doing the sort.  what you have two css selector definitions, one  for
> > > the rows of your data and the other is the css selector information for
> > > the element that holds the information that you want to sort on
> > >
> > > basically what you would end up with is
> > >
> > > $.sort("table.report tbody tr", "td.name a");
> > >
> > > would sort the following table into alphabetic order
> > >
> > > <table class='report'>
> > >   <thead>...</thead>
> > >   <tbody>
> > >     <tr><td class='name'><a href='zebra.html'>zebra</a></td><td>Looks
> > > like a horse with stripes</td></tr>
> > >     <tr><td class='name'><a href='tiger.html'>tiger</a></td><td>Looks
> > > like a horse with stripes but with sharp teeth.</td></tr>
> > >   </tbody>
> > > </table>
> > >
> > > I think that this would be a great addition to the jQuery base class or
> > > should it just be a plugin.
> > >
> > > $(document).ready(function(){
> > >   var rows = [];
> > >   $("table.report tbody tr").each(function(){
> > >     rows[rows.length] = [$(this).find("td.name a").html(),this];
> > >   });
> > >   rows.sort(function(a,b){
> > >     if (a[0] < b[0]) {
> > >       return -1
> > >     } else if (a[0] > b[0]) {
> > >       return 1
> > >     } else {
> > >       return 0;
> > >     }});
> > >   $.each(rows, function() {
> > >     this[1].parentNode.appendChild(this[1]);
> > >   });
> > > });
> > >
> > > I'll look into adding this to the jQuery-latest.js code later
> > >
> > > Adrian Sweeney
> > >
> > >
> > >
> > > ___________________________________________________________
> > > All New Yahoo! Mail – Tired of [EMAIL PROTECTED]@! come-ons? Let our 
> > > SpamGuard protect you. http://uk.docs.yahoo.com/nowyoucan.html
> > >
> > >
> > >
> > >
> > > _______________________________________________
> > > jQuery mailing list
> > > discuss@jquery.com
> > > http://jquery.com/discuss/
> > >
> > >
> > >
> >
> >
>
> Send instant messages to your online friends http://uk.messenger.yahoo.com
>
>
> _______________________________________________
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>


-- 
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to