#10970 closed bug (fixed)
The .on() selector parameter doesn't work with :not(:first) selector
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | low | Milestone: | 1.7.2 |
Component: | event | Version: | 1.7.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I'm using the .on() selector in this manner:
$(document).on("click", "#users_table tr", function (event) {
and it works. If I add the :not(:first) (which works in any other selector usage), the event is not triggered on all rows (instead of not triggering only on the first row)
$(document).on("click", "#users_table tr:not(:first)", function (event) {
Change History (7)
comment:1 Changed 11 years ago by
comment:2 Changed 11 years ago by
Component: | unfiled → event |
---|---|
Priority: | undecided → low |
Status: | new → open |
Confirmed on latest Chrome/Firefox. Improved testcase
As a temporary workaround, you can use tr:gt(0)
instead.
You should also use delegating instead of live:
http://jsfiddle.net/mofle/4QqtR/
comment:3 Changed 11 years ago by
Looks like two problems here. One is with the POS regexp in .is(), it isn't sending :first to the positional selector route. Then there seems to be a bug in Chrome where a selector with :first in it returns false rather than throwing, which is should since that's a non-standard selector.
However, using positional selectors in a case like that is a very bad idea because it is much less efficient than a standard selector. It has to select all the elements that apply and see if the one you are asking about is in that set.
You can use :first-child instead and it works.
comment:4 Changed 11 years ago by
False alarm on the Chrome bug, it seems to be working fine. We're working on the regexp issue.
comment:6 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | open → closed |
Use Sizzle.Expr.match.globalPOS for identifying POS selectors in traversing. Fixes #10970.
Changeset: 2a63b980eda1cf4ec1c2f27749821785c78c65b6
comment:7 Changed 11 years ago by
Milestone: | None → 1.7.2 |
---|
The working example on jsfiddle: http://jsfiddle.net/LMeFc/2/