[jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-15 Thread stephb...@googlemail.com
> The only drawback when using the this method is that users will not be > able to support multiple event names within the same bind call: And as I pointed out, you can't expect this to work: $(context).bind('a.menu:first:click.namespace', fn); Whereas this would work, as well as allowing multip

[jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-14 Thread xwisdom
Here's what I would use to separate the selector from the event name: var sel,event = 'a.menu:click.namespace'; if (event.indexOf(':')) { sel = event.substr(0,event.lastIndexOf(':')); event = event.replace(sel+':',''); } alert('selector:'+ sel +" \nevent:" + event

[jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-14 Thread stephb...@googlemail.com
On Nov 13, 5:06 pm, xwisdom wrote: > $(context).bind('a.menu:click', callback); The event name has to be able to support any string (to include custom events), and the selector has to be able to support any selector. Because selectors already have stuff like ':eq(n)', your suggestion of ':eventT

[jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-14 Thread stephb...@googlemail.com
On Nov 13, 5:06 pm, xwisdom wrote: > $(context).bind('a.menu:click', callback); This is what the special event that I described (in a long-winded comment) earlier does, albeit with a slightly different syntax: $(context).bind('click', { selector: 'a.menu' }, callback); Here, again, is the cod

[jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-13 Thread xwisdom
Hi John, After thinking about it for sometime. I really think it would be good to have an optimized version of the live call. Here's an example of what I'm thinking of: $(context).bind('a.menu:click', callback); The above would internally use the live() method to setup the click event for every

[jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-12 Thread seasoup
I don't think this is as much of an edge case as John thinks. I've run into it as well. Another way around it is to set the .live events outside of the document load listener in the head. That way, it runs before the selector returns any results. I can see why it was placed where it is, so you

[jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-08 Thread Robert Katić
I opened a ticket: http://dev.jquery.com/ticket/5475 On Nov 8, 12:50 am, Robert Katić wrote: > oops: "evaluated without context" > > On Nov 8, 12:48 am, Robert Katić wrote: > > > I detect only now that in closest method the selector is evaluated > > without selector. > > I am not sure which cont

[jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-07 Thread Robert Katić
oops: "evaluated without context" On Nov 8, 12:48 am, Robert Katić wrote: > I detect only now that in closest method the selector is evaluated > without selector. > I am not sure which context is more correct: (context || this.context) > or it have to be a document? > > PS: It is not completely c

[jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-07 Thread Robert Katić
I detect only now that in closest method the selector is evaluated without selector. I am not sure which context is more correct: (context || this.context) or it have to be a document? PS: It is not completely clear to me why selectors with positions can not be handled by multiFilter in this situa

Re: [jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-07 Thread John Resig
I've already landed the commits - looks great - thanks! (I'll close the ticket once my network stops flaking out.) --John On Sat, Nov 7, 2009 at 5:47 PM, Robert Katić wrote: > I opened a ticket: http://dev.jquery.com/ticket/5470 > with link on commit. > > Commit also includes context inside li

[jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-07 Thread Robert Katić
I opened a ticket: http://dev.jquery.com/ticket/5470 with link on commit. Commit also includes context inside liveHandler (it is a too small change to make a separate commit). Component is "unfiled". Please tell me if I made mistakes opening this ticket. On Nov 6, 3:01 pm, John Resig wrote: > >

[jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-07 Thread stephb...@googlemail.com
To handle click delegation I took the approach of enhancing the click event using the special events framework. This might be a slight tangent to this thread, but it does address many of the problems discussed here. Here's the code: http://webdev.stephband.info/events/click/js/jquery.event.click

[jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-05 Thread Robert Katić
Regarding improving live(), I would note two things about liveHandler: 1. Calling closest, context argument still is not used. I was unable to find the proper ticket. Would I open one? 2. Storing "how much a parent is close to an element" with data API is an big overhead. An jQuery.lastCloser or

Re: [jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-05 Thread Robert Katić
No you will not. My Mistake --Robert On 6. stu. 2009., at 05:29, John Resig wrote: > If you want to limit, just do this (using the nightlies): > > $("#someRootTable").click(function(e){ > $(e.target).closest("td.foo", this).each(function(){ > // Your code goes here. > }); > }); > > Still

Re: [jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-05 Thread Robert Katić
I suppose you will need an "return false;" too at the end of the handler... --Robert On 6. stu. 2009., at 05:29, John Resig wrote: > If you want to limit, just do this (using the nightlies): > > $("#someRootTable").click(function(e){ > $(e.target).closest("td.foo", this).each(function(){ >

Re: [jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-05 Thread John Resig
If you want to limit, just do this (using the nightlies): $("#someRootTable").click(function(e){ $(e.target).closest("td.foo", this).each(function(){ // Your code goes here. }); }); Still pretty simple and requires no additional functionality. I may just write this up as an example and a

Re: [jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-05 Thread Robert Katić
$("#someRootTable").delegate("td.foo", "click", function(e){ // Your code goes here. }); Would be easer and safer because the event will be handlet only by "td.foo" elements inside "#someRootTable". --Robert On 6. stu. 2009., at 04:56, John Resig wrote: > $("#someRootTable").click(functi

Re: [jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-05 Thread Nik Pasaran
What about something like this: $.live = function(selector, type, callback) { $.fn.live.call({ selector: selector }, type, callback); } On Thu, Nov 5, 2009 at 7:13 AM, xwisdom wrote: > Hi John, > > Thanks for the quick feedback > > IMO, I think it would be handy to have somethin

Re: [jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-05 Thread John Resig
> Also, @robert, my solution supports the following notation, similar to > yours but using the familiar jQuery syntax (before/after DOMReady): > $.live("#mySelector", "click", fn1) >  .live("#mySelector", "mouseover", fn2) >  ...; I understand the logic behind you wanting a $.live method (for the

[jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-05 Thread furf
I don't think that the method name is at question here, but rather the unnecessary performance cost of querying a selector before DOMReady (or even after), ie. $('#anything'), when it is not needed for the event delegation pattern. The .live method uses only the .selector property of the jQuery ins

Re: [jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-05 Thread Robert Katić
Meyer, "delegate" was my first candidate too but I was worry that it was overused :). Seams that I was wrong. Will update it with "delegate" ASAP. --Robert On 6. stu. 2009., at 02:42, Justin Meyer wrote: > How about $("#something").delegate(".thing","click", func). > > It almost makes too m

[jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-05 Thread Justin Meyer
How about $("#something").delegate(".thing","click", func). It almost makes too much sense :). On Nov 5, 6:31 pm, Robert Katić wrote: > I wonder why there would be an $.live with document as the only > interesting context. > > Something like > >   $(document).zombi(selector, type, ...) > > would

[jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-05 Thread Robert Katić
I wonder why there would be an $.live with document as the only interesting context. Something like $(document).zombi(selector, type, ...) would be more flexible (I know, "zombi" is not nice, but I have no inspirations about a more suitable name). To avoid to repeat selector on multiple bindi

[jquery-dev] Re: Will the live() method be improved in 1.4?

2009-11-05 Thread furf
I've also been among those clamoring for an optimized $.live method and have a offered similar hack around in the past (via Paul Irish's Anti-Patterns). Last night on the flight to jsconf, I hacked up a more formal patch which puts optimized live and die methods into the jQuery root and aliases th