Gee, I've just read my last post: I couldn't understand my point :).
Sorry about that, I will give it a new shot:
Consider the tree:
<ul class="treeview">
  <li><a><span>el 1</span></a></li>
  <li><a><span>el 2</span></a></li>
  <li>
    <a><span>el 3</span></a>
    <ul>
      <li><a><span>el 3.1</span></a></li>
      <li><a><span>el 3.2</span></a></li>
      <li>
        <a><span>el 3.3.1</span></a>
        <ul>
          <li><a><span>el 3.3.1</span></a></li>
        </ul>
      </li>
    </ul>
  </li>
</ul>

Goal is: when clicked on el "3.3.1" to navigate to "el 3", click event
is bundled with the <span> element. This means: I want the <span>
surrounding 'el 3'

My idea: despite the depth of the list 'e.parents( 'li', $
('ul.treeview') );' returns a set ot <li> elements. one of this <li>
elements is a direct descendant of the top <ul> list, so selecting the
<span> element inside this <li> is made by .children().children()[0].
Because of my unadvanced knowledge about the selectors I'm making this
by iterating the resultset and checking each one element to see if it
fits my criteria.

The Problem: let's say 'e' points to a single element, consider this:
console.log( e ); // --> [span]
var p = e.parents( 'li', $('ul.treeview') );
console.log( e ); // --> [li]
console.log( p ); // --> [li]

or, which is even more frustrating:
foo( 1,2 )
function foo() {
  var a = arguments;
  console.log( a ); // --> [1,2]
  var e = $( $( 'span' )[a[0]] );
  console.log( e ); // --> [span]
  var p = e.parents( 'li', $('ul.treeview') );
  console.log( a ); // --> [li]
  console.log( e ); // --> [li]
  console.log( p ); // --> [li]
}

jQuery version is: 1.0.4 and unfortunately I can't change it

Now, let's hope I've managed it to be more precise about my
thoughts :)

Greetings
-- Nikola

Reply via email to