I haven't seen your page, but I know that styling <dd> and <dt>
elements for IE is a pain. And the invalid mark-up might bring you
problems with different browsers. The usual behavior for invalid
nesting is to close the offended tag to make it valid, so this

<dl>
  <dt>
    <div></div>
  </dt>
  <dd/>
</dl>

would become

<dl>
  <dt>
  </dt>
</dl>
<div></div>
<dl>
  <dd/>
</dl>

Firefox is surprisingly tolerant in this case, but I haven't tested
elsewhere. Valid mark-up is a safe harbour specially with regards to
DOM manipulation.

That aside, I found the issue, it's actually quite simple.

this.parents('dl:not(:first)')

let's see what's happening:
- first, this gets you all the parents() for 'root'. Without any
filtering, that would be DD, DL, DD, DL etc.
- then you ask it to filter the elements which are 'DL's AND are not
the first match. Here's the catch: :first refers to the first match in
the set, which is a DD element, not a DL one. The DL is never going to
be the first match.

:first will always filter according to the current set, before any
other expressions in the same call are evaluated. So what you need to
do is filter the parents set again:

var slots = $(this).parents('dl').filter(':not(:first)').map(function
() {
      return $(".Texto:first", $(this)).text();
}

Or use slice() instead as I posted before, that will be much faster as
you're just slicing the array without dealing with elements/selectors.

var slots = $(this).parents('dl').slice(1).map(function() {
      return $(".Texto:first", $(this)).text();
}

cheers,
- ricardo

On Feb 2, 11:35 am, Garito <gar...@gmail.com> wrote:
> Sorry Ricardo but you say the problem is the dt element?
>
> With this markup I can do what I need in terms of css
>
> With the css I put the divs inside the dt element to put a label, the
> icon and the other div to switch between visible/non visible dd
>
> How do you think I could put my markup to avoid this problem?
>
> I don't like your suggest because one of the main reasons to change
> from prototype to jquery was the css's selectors and they power
>
> I thinks this is a jquery's bug, isn't it?
>
> On 2 feb, 10:02, Ricardo Tomasi <ricardob...@gmail.com> wrote:
>
> > Ah that's quite confusing mark-up. A <dt> element can only contain
> > inline elements, certainly not divs and other definition lists. Nested
> > definition lists make no sense! I couldn't find the problem.
>
> > Try $(this).parents('dl').slice(1) or $(this).parents('dl').slice
> > (0,-1), that will probably work.
>
> > cheers,
> > - ricardo
>
> > On Feb 1, 10:57 pm,Garito<gar...@gmail.com> wrote:
>
> > > Gracias, Ricardo!
> > > I change the code with the complete test case for my issue
>
> > > Sorry for the identation but the original code is generated and I copy/
> > > paste with firebug
>
> > > If I'm not wrong, with the selector 'dl:not(:last)' SITE dl is
> > > incorrect in the returned list because is the last dl (if not 'dl'
> > > will be equal to 'dl:not(:last)')
>
> > > am I confused or there is a bug?
>
> > > Thanks!
>
> > > On 1 feb, 21:07, Ricardo Tomasi <ricardob...@gmail.com> wrote:
>
> > > >http://jquery.nodnod.net/cases/85
>
> > > > Parece ok aqui. Pode ser alguma outra coisa na tua página, não dá pra
> > > > saber sem ver o html.
> > > > --------
> > > > Seems to work fine here. Could you post a complete test page showing
> > > > this issue?
>
> > > > - ricardo
>
> > > > On Feb 1, 1:25 pm,Garito<gar...@gmail.com> wrote:
>
> > > > > Hi!
> > > > > Please, consider this code:
>
> > > > > $.fn.url2 = function(absoluta) {
> > > > >                 var slots = 
> > > > > $(this).parents('dl:not(:last)').map(function() {
> > > > >                         return $(".Texto:first", $(this)).text();
> > > > >                 });
> > > > >                 var slots2 = $(this).parents('dl').map(function() {
> > > > >                         return $(".Texto:first", $(this)).text();
> > > > >                 });
> > > > >                 return slots.get().join("/") + ' -- ' + 
> > > > > slots2.get().join("/");
> > > > >         };
>
> > > > > The funny thing of this code is that slots and slots2 have the same
> > > > > items
> > > > > Could you point me why slots put the last dl?
>
> > > > > I suppose that dl:not(:last) retrieves all the parents except the last
> > > > > one but this don't work
>
> > > > > Thanks!

Reply via email to