Here's the relevant snippet. It uses the value of a checkbox to show or
hide content based on the class name given to a div around said content.
iFilter is a numerical value based on bit addition. Or something.
iGroups is the number of filterable groups I have (in this case,
currently 2).

// perform showing / hiding of appropriately marked content according to
whether it has been marked for filtering.
function filter(iFilter)
{
        // We'll be performing bitwise AND operations (&) to essentially
provide a true or false value
        if (iFilter == 0)
        {
                iFilter = Math.pow(2, iGroups) -1;
        }
        for (i = 1; i < (Math.pow(2, iGroups)); i++)
        {
                target = ".f" + i; // The CSS class of the filterable
content

                if (iFilter & i) // show content
                {
                        $(target).parent().show();
                }
                else // hide content
                {
                        $(target).parent().hide();
                }       
        }
}

Not sure how much use that will be to you but it works on all modern
browsers :)

There's probably a much better way to do this. I'm very new to jQuery.

In fact, I historically refused to do client side until jQuery (for
scripting) and YUI (for handling CSS woes) came along because it was
just too much like hard work. How times change.

Richard

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of GianCarlo Mingati
Sent: 03 April 2008 14:02
To: jQuery (English)
Subject: [jQuery] Re: hide() and floating elements leaves white space


Ciao Richard,
i'm glad you get the solution.
could you show us the piece of code you used?
i don't understand (and i'm always curious to 'see') what you click to
remove the LI.
Is it a LI with an A and an IMG?
If so, when you remove() an element don't you 'destroy' it? How do you
pass it back as the target?

GC


On 3 Apr, 11:33, "Richard Weeks" <[EMAIL PROTECTED]> wrote:
> Thanks, that prompted me to think correctly.
>
> The solution is even simpler. The element I was show / hiding was
within
> an li element and it was this being left that led to space remaining
on
> removal of the contained element (in IE of course).
>
> What I did instead was remove the li, i.e. the parent:
>
> $(target).parent().hide();
>
> And...
>
> $(target).parent().show();
>
> Where target is the name of the element.
>
> That works very nicely.
>
> Richard
>
> -----Original Message-----
> From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED]
On
>
> Behalf Of GianCarlo Mingati
> Sent: 02 April 2008 15:22
> To: jQuery (English)
> Subject: [jQuery] Re: hide() and floating elements leaves white space
>
> i think you should get a copy of the markup of the entire LI element
> you want to hide, and pointing to that LI element onclick
> you .remove() it.
> To reappend it, store the position of the removed li (.eq(n)), and re
> - insertAfter() the element that precedes the one you removed...
> ??
>
> On Apr 2, 11:53 am, "Richard Weeks" <[EMAIL PROTECTED]>
> wrote:
> > This is killing me! Due to the rule of supply and demand, I'm sure
> there
> > must be a workaround as there are so many people in forums searching
> for
> > the same grail...
>
> > Picture a list:
>
> > A B C
> > D E F
> > G H I
>
> > The list items are floating left, using CSS, on a fixed width to
> > simulate 3 columns.
>
> > If I call .hide() on item 'E', no matter what I do, I am left with:
>
> > A B C
> > D # F
> > G H I
>
> > (# = space)
>
> > What I want is:
>
> > A B C
> > D F G
> > H I
>
> > CSS "display-inline" doesn't work as you can't set width on an
inline
> > element. Is there something I can do with jQuery to get the expected
> > behaviour?
>
> > Thanks,
>
> > Richard

Reply via email to