Side navigation
#10070 closed bug (worksforme)
Opened August 17, 2011 11:09AM UTC
Closed August 18, 2011 03:01PM UTC
Last modified September 21, 2011 01:38PM UTC
$(selector, context) documentation clarification
Reported by: | guffa@guffa.com | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.6.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
In the documentation the context in a search has to be:
context A DOM Element, Document, or jQuery to use as context
However, a selector string also seems to work, and people use it that way, e.g.:
$('a', '.container')
The option to use a selector should be included in the documentation, or if that option is unintended and unwanted, an example on how to use a selector as context by creating a jQuery object from it, i.e.:
$('a', $('.container'))
An example where such a use would be plausible:
function getLinks(parentSelector) { return $('a', $(parentSelector)) } getLinks('.container').css('color','red');
Attachments (0)
Change History (4)
Changed August 18, 2011 03:01PM UTC by comment:1
keywords: | → needsdocs |
---|---|
resolution: | → worksforme |
status: | new → closed |
Changed August 18, 2011 10:33PM UTC by comment:2
If you feel that it should not be supported, why did you close the ticket?
The code ''does'' support it, and if that is not desired, it should be changed.
Changed August 19, 2011 04:09AM UTC by comment:3
When I say "encourage and support" I mean in terms of best practices. Yes it works, and I am not advocating we change the behavior. I am simply saying it is a convoluted way of doing something so I would prefer not to encourage it.
That's why the ticket is marked needsdocs
, needing discussion about documentation. There is no change required to the code, so the ticket can be closed and the documentation addressed later.
Changed September 21, 2011 01:38PM UTC by comment:4
keywords: | needsdocs |
---|
People may use it that way, but should we encourage and support it? I don't see a reason to do so.
$(".container a")
is a lot more obvious than$("a", ".container")
.Since it's a docs issue I'll close this ticket and mark it
needsdocs
for later discussion.