[jQuery] Re: Splitting long lists

2007-12-18 Thread Alex

See! I *knew* there was a better way. Thanks for the example - it
works like a charm and I learned a new math function. It did take me a
minute to spot your typo - a comma and period seriously need to be
more than two pixels different:

var to = jQuery(''),attr({id:list+'-b',class:cssClass})


Thanks much!


On Dec 18, 4:54 pm, Wizzud <[EMAIL PROTECTED]> wrote:
> A possible alternative (untested!) to ponder upon...
>
> function balance(list,cssClass){
>  // new second 'half' of list...
> var to = jQuery(''),attr({id:list+'-b',class:cssClass})
>  // original list, with new id and class, and new list placed
> after...
>, from = jQuery('#'+list).attr({id:list+'-
> a'}).addClass(cssClass).after(to)
>  // list of items...
>, items = jQuery('li', from)
>;
> // move bottom 'half' of list from from to to...
> to.append( items.slice(Math.ceil(items.length/2), items.length) );
>
> }
>
> On Dec 18, 5:14 pm, Alex <[EMAIL PROTECTED]> wrote:
>
> > Another patch, as I realized I needed to round the number of list
> > items, otherwise it wouldn't work with uneven lists. Replace
>
> > var itemsLength = items.length/2;
>
> > with
>
> > var itemsLength = Math.round(items.length/2);


[jQuery] Re: Splitting long lists

2007-12-18 Thread Wizzud

A possible alternative (untested!) to ponder upon...

function balance(list,cssClass){
 // new second 'half' of list...
var to = jQuery(''),attr({id:list+'-b',class:cssClass})
 // original list, with new id and class, and new list placed
after...
   , from = jQuery('#'+list).attr({id:list+'-
a'}).addClass(cssClass).after(to)
 // list of items...
   , items = jQuery('li', from)
   ;
// move bottom 'half' of list from from to to...
to.append( items.slice(Math.ceil(items.length/2), items.length) );
}

On Dec 18, 5:14 pm, Alex <[EMAIL PROTECTED]> wrote:
> Another patch, as I realized I needed to round the number of list
> items, otherwise it wouldn't work with uneven lists. Replace
>
> var itemsLength = items.length/2;
>
> with
>
> var itemsLength = Math.round(items.length/2);


[jQuery] Re: Splitting long lists

2007-12-18 Thread Alex

Another patch, as I realized I needed to round the number of list
items, otherwise it wouldn't work with uneven lists. Replace

var itemsLength = items.length/2;

with

var itemsLength = Math.round(items.length/2);


[jQuery] Re: Splitting long lists

2007-12-17 Thread Alex

Just ran into this bug in IE 6 and 7: using "class" trigger's IE's
reserved keyword garbage, so one improvement should be replacing the
variable "class" with anything else - maybe "cssClass".