> 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
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
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
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
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
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
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
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
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
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
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:
> >
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
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
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
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(){
>
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
$("#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
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
> 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
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
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
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
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
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
24 matches
Mail list logo