[jquery-dev] Re: enhancing closest delegation

2009-07-27 Thread Andrea Giammarchi
wow, all this stuff sonds like a path finder AI algo a la A* (A Star) in a mono column grid with optional context as obstacle in the north direction ... did anybody of us think about some algo to quickly map the DOM in a 3D space? ... seriously, nested nodes are up in the Z scale, documentElement

[jquery-dev] Re: enhancing closest delegation

2009-07-24 Thread mike.helgeson
Alright, the context sounds good, pardon my confusion. On Jul 23, 2:59 pm, John Resig jere...@gmail.com wrote: It will make the specific context required anytime raw nodes are used Hmm... no it won't? $( event.target ).closest(.foo); // will still work, starts at event.target. goes up

[jquery-dev] Re: enhancing closest delegation

2009-07-23 Thread Jörn Zaefferer
I don't follow. What does make the above .closest() context change mean? Jörn On Thu, Jul 23, 2009 at 5:12 AM, John Resigjere...@gmail.com wrote: Not to mention it would either be broken, or be a complete hack. $(selector, context); is actually an alias for $(context).find(selector); And

[jquery-dev] Re: enhancing closest delegation

2009-07-23 Thread John Resig
Brandon mentioned making it so that you could do: $(Something, SomeContext).closest(div); And closest would limit its search to within the context of the original $(...). The problem is that: $(DOMElement, DOMElement) Doesn't work right now (the context is ignored). Thus, we need to make it

[jquery-dev] Re: enhancing closest delegation

2009-07-23 Thread John Resig
A big distinction between the two proposals is if DOMElement is not contained in DOMElementContext: $(DOMEelement,DOMElementContext).closest(body); returns $([]); $(DOMEelement).closest(body,DOMElementContext); returns $(body); I vote for the 2nd argument. In what case would you want to

[jquery-dev] Re: enhancing closest delegation

2009-07-23 Thread Brandon Aaron
Well specifically context is used in .live(). A .live() event handler will be bound to the context. However, the .closest() method will look beyond the context. The context should limit the actions of jQuery to within the context's children. -- Brandon Aaron On Wed, Jul 22, 2009 at 4:28 PM,

[jquery-dev] Re: enhancing closest delegation

2009-07-23 Thread Daniel Friesen
While what is being talked about here is confusing me, there are valid uses for a method of restricting a .find based on a selector. That's a feature I'd like to see. $(NavFrame).find('.NavContent, .NavPic' /* some way of restricting to outside nested .NavFrames */); That being said, I

[jquery-dev] Re: enhancing closest delegation

2009-07-23 Thread mike.helgeson
In what case would you want to find the closest() match but outside of a context? $( this ).closest(.foo); currently $( this ).context is equal to this What's the point of providing a context then if most closest() queries will just ignore the context away? I don't think the context

[jquery-dev] Re: enhancing closest delegation

2009-07-23 Thread John Resig
In what case would you want to find the closest() match but outside of a context? $( this ).closest(.foo); currently $( this ).context is equal to this Sorry, you misunderstand me - I meant that with your proposed case: $(DOMEelement).closest(body, DOMElementContext); returns $(body);

[jquery-dev] Re: enhancing closest delegation

2009-07-23 Thread mike.helgeson
I have no specific use case in mind for that particular example. I was thinking of the second closest argument would act like a break statement rather than a search within context. Still, If the context is used to limit the traversal of the closest loop, how would you set the context of raw DOM

[jquery-dev] Re: enhancing closest delegation

2009-07-23 Thread John Resig
I have no specific use case in mind for that particular example. I was thinking of the second closest argument would act like a break statement rather than a search within context. Still, If the context is used to limit the traversal of the closest loop, how would you set the context of raw

[jquery-dev] Re: enhancing closest delegation

2009-07-23 Thread mike.helgeson
The point I am trying unsuccessfully to make is that the context change will break existing code. It will make the specific context required anytime raw nodes are used, which is probably the most common closest usage pattern. Instead of using the context, if a 2nd argument is added to the

[jquery-dev] Re: enhancing closest delegation

2009-07-23 Thread John Resig
It will make the specific context required anytime raw nodes are used Hmm... no it won't? $( event.target ).closest(.foo); // will still work, starts at event.target. goes up to documentElement $( event.target, context ).closest(.foo) // starts at event.target, doesn't go higher than context

[jquery-dev] Re: enhancing closest delegation

2009-07-22 Thread Daniel Friesen
http://dev.jquery.com/ticket/4072 I believe John liked it to when I mentioned it in the mailing list. It was one of those things on my list of things missing in jQuery compared to the bad local framework I wrote for an app at work. ~Daniel Friesen (Dantman, Nadir-Seen-Fire)

[jquery-dev] Re: enhancing closest delegation

2009-07-22 Thread Brandon Aaron
I think it should just stop at the context of the jQuery object. So you'd do this instead: $(table).bind(click, function( event ) { var $td = $(event.target, this).closest(td); }); -- Brandon Aaron On Wed, Jul 22, 2009 at 1:07 PM, mike.helgesonmike.helge...@gmail.com wrote: I propose

[jquery-dev] Re: enhancing closest delegation

2009-07-22 Thread mike.helgeson
That makes a lot of sense, except it does not work. The context property of the jquery instance is always equal to the first element when passing in DOM nodes. Unless I am mistaken. On Jul 22, 4:33 pm, Brandon Aaron brandon.aa...@gmail.com wrote: I think it should just stop at the context of

[jquery-dev] Re: enhancing closest delegation

2009-07-22 Thread Jörn Zaefferer
Working or not, having public API methods rely on the context-property doesn't seem like a great idea - is that the case anywhere else? Jörn On Wed, Jul 22, 2009 at 11:32 PM, mike.helgesonmike.helge...@gmail.com wrote: That makes a lot of sense, except it does not work. The context property

[jquery-dev] Re: enhancing closest delegation

2009-07-22 Thread Daniel Friesen
Not to mention it would either be broken, or be a complete hack. $(selector, context); is actually an alias for $(context).find(selector); And this.context isn't what was passed to context. ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name] Jörn Zaefferer wrote: Working

[jquery-dev] Re: enhancing closest delegation

2009-07-22 Thread John Resig
Not to mention it would either be broken, or be a complete hack. $(selector, context); is actually an alias for $(context).find(selector); And this.context isn't what was passed to context. I remember the case of $(DOMElement, DOMElement) being discussed recently as an alias for