Friday, May 1, 2009

[jQuery] problem filtering out via parents() and :not()

Hello !
I'm assigning a specific "swap position" behaviour on click to a list
of links, all sitting inside a multilevel unordered list with id
"detailsNavigation"

That behaviour only concerns specific anchors and those with class
"noSwap" shouldn't ... swap.

Can you explain me why this does not work?


$("#detailsNavigation li ul li a").bind("click", function()
{
var $thisA = $(this);
var $thisLI = $thisA.parent();
var $thisUL = $thisLI.parent();
if ($thisUL.parents('li').is(':not("#metadesign,
#editions, #timeline, #related")') || $thisA.is(':not(".noSwap")'))
{
// do that swappin' thingy
}
});


Here is the related html:

<ul>
<li class="clearfix" id="metadesign">

<ul style="display: block;" class="detailsSubnav clearfix
selected">
<li class="clearfix" style="width: 100%;">
<ul class="metaSection clearfix">
<li class="skinColor
metaSectionTitle">concepts</li>
<li><a class="ajax noSwap" href="http://m2.lab-
au.com/projects/f551/metadesign/concepts/8/">
electrosensing</a></li>
</ul>
<ul class="metaSection clearfix">
<li style="display: list-item;">
<a class="ajax selected noSwap" href="http://
m2.lab-au.com/projects/f551/metadesign/methods/
referencing/
">referencing</a>
</li>
<li class="skinColor
metaSectionTitle">methods</li>
<li class="inactive"><span
class="inactive">Data mining</span></li>
</ul>
</li>
</ul>
</li>
</ul>

Thanks a lot for your help!

Alexandre

No comments: