Opened 13 years ago
Closed 12 years ago
#7063 closed enhancement (fixed)
[patch][cla] Add method to reference single items in a NodeList
Reported by: | guest | Owned by: | dante |
---|---|---|---|
Priority: | high | Milestone: | 1.2 |
Component: | Core | Version: | 1.1.1 |
Keywords: | NodeList | Cc: | |
Blocked By: | Blocking: |
Description
I often find myself wanting to work with a single item in a NodeList? but without losing all the wonderful features of the NodeList?. For example, to connect to a click event for a single item, you have to do something like:
dojo.connect(dojo.query("...")[2], "onclick", ...);
I suggest adding a method, maybe named at
, items
, or get
(a la jQuery) that would take a list of indices and return them as a new NodeList?. It's sort of like slice
but not quite. Some examples...
Add a click handler to the first paragraph:
dojo.query("p").at(0).onclick(...);
Do something with the 3rd, 5th and 9th paragraph:
dojo.query("p").at(3,5,9).forEach(...);
Attachments (1)
Change History (3)
Changed 13 years ago by
Attachment: | NodeList-at.diff added |
---|
comment:1 Changed 13 years ago by
Milestone: | → 1.2 |
---|---|
Owner: | changed from anonymous to dante |
Summary: | Add method to reference single items in a NodeList → [patch][cla] Add method to reference single items in a NodeList |
Note: See
TracTickets for help on using
tickets.
Patch to add "at" method --D. Schontzler