Side navigation
#11728 closed bug (fixed)
Opened May 08, 2012 03:13PM UTC
Closed May 11, 2012 08:48PM UTC
Documentation for .one (delegated events)
Reported by: | NTICompass@gmail.com | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | event | Version: | 1.7.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
In the docs for .one(), it says:
>identical to .on() except that the handler is removed after the first time the event occurs at the delegated element, whether the selector matched anything or not
It also contains the example:
$("body").one("click", "#foo", function() { alert("This displays if #foo is the first thing clicked in the body."); });
I figured this meant, that once I clicked on the body, whether I clicked on #foo or not didn't matter, and the event would be removed. This doesn't seem to be the case, the event isn't removed until #foo is clicked on.
DEMO 1: http://jsfiddle.net/xKrPQ/ DEMO 2: http://jsfiddle.net/xKrPQ/1/
What is the correct behavior here?
Attachments (0)
Change History (3)
Changed May 11, 2012 05:51PM UTC by comment:1
component: | unfiled → event |
---|---|
keywords: | → needsdocs |
priority: | undecided → low |
Changed May 11, 2012 05:56PM UTC by comment:2
Replying to [comment:1 dmethvin]:
Yeah, I guess the docs were a bit confusing. Your explanation makes sense, thanks.
Changed May 11, 2012 08:48PM UTC by comment:3
keywords: | needsdocs |
---|---|
resolution: | → fixed |
status: | new → closed |
Docs updated.
It's a documentation bug ... my documentation bug.
What it is trying to differentiate there is that for this case:
Each of the elements with class
.lotsOfElements
gets its own "one" click. But for delegated events,The first element clicked element with class
.lotsOfElements
fires the event handler and that's it. I'll clarify in the docs.