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, Jörn Zaefferer<joern.zaeffe...@googlemail.com> wrote: > > 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.helgeson<mike.helge...@gmail.com> > wrote: >> >> 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 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.helgeson<mike.helge...@gmail.com> >>> wrote: >>> >>> > I propose adding a second argument to the "closest" method that will >>> > act as the end point for searching up the document tree. It can behave >>> > just like the "context" argument in the jQuery mother function. It >>> > will optimize the performance of a common pattern I have seen in my >>> > own code since the addition o this method. >>> >>> > $("table").bind("click",function( event ){ >>> > var $td = $( event.target ).closest("td", this ); >>> > }); >>> >>> > Because I bound the handler to "table" I do not want to search an >>> > higher than that element for selector matches. Furthermore, if there >>> > was a selector match outside of the containing element, it could >>> > potentially and accidentally be matched. >>> >>> >http://dev.jquery.com/ticket/4945 >>> >>> > Any thoughts? >> > >> > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---