Filed as http://dev.jquery.com/ticket/4072 However whitespace has been trimmed so it doesn't look that great.
Just a side note, but I left the component "unfilled" as there is no "traversing" component. Perhaps one could be added as the closest component there is "selector" but that's really for Sizzle/old selector related bugs. ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://nadir-seen-fire.com] -Nadir-Point (http://nadir-point.com) -Wiki-Tools (http://wiki-tools.com) -MonkeyScript (http://monkeyscript.nadir-point.com) -Animepedia (http://anime.wikia.com) -Narutopedia (http://naruto.wikia.com) -Soul Eater Wiki (http://souleater.wikia.com) Ariel Flesler wrote: > It makes a lot of sense and would actually improve perfomance and > accurracy for some uses. Not for live() though (our only closest > application). > > We are planning on allowing other contexts (than document). Once we do > that, this 3rd parameter would become meaningful for live(). > > Can you add a ticket filed as enhancement ? > http://dev.jquery.com/newticket > > -- > Ariel Flesler > http://flesler.blogspot.com > > > On Feb 4, 7:37 pm, Daniel Friesen <[email protected]> wrote: > >> I have a function similar to the .closest method in jQuery inside of >> my framework. I was wondering if it was a good idea to have .closest >> accept am optional second argument (restriction) to it like my own. >> >> In my framework I use pf.trace (tracing backwards through the dom) >> almost precisely the same as .closest; >> >> pf('#foo').click(function(e) { >> var elm = pf.trace(e.target, 'li', this); >> if(!elm) return; >> >> ... >> >> }); >> >> The third argument is a restriction. You can basically read that as >> "trace backwards through the dom starting at e.target and return the >> first li tag found, don't return any node if you hit 'this'. >> >> The third argument is a restriction so basically in a case like: >> <ul> >> <li> >> <ul id="foo"> >> <li>...</li> >> <ul> >> <li> >> </ul> >> >> If you clicked on the ul#foo instead of the li inside of it (things >> like that are quite possible after you've done styling) then just >> using .closest('li') will return the parent li which you don't want. >> Another argument could serve as a restriction to the check. >> > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---
