Side navigation
#9392 closed feature (wontfix)
Opened May 22, 2011 07:15PM UTC
Closed June 07, 2011 06:53PM UTC
Last modified March 09, 2012 04:42AM UTC
Add :data() Selector
Reported by: | kaneiderdaniel@gmail.com | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.7 |
Component: | selector | Version: | 1.6.1 |
Keywords: | 1.7-discuss | Cc: | |
Blocked by: | Blocking: |
Description
Provide a selector for .data(), similar to those of attributes:
Example with attributes
- $("".someClass[myAttr])
- $("".someClass[myAttr='someValue'])
Likewise something for .data
- $("".someClass:hasData(myAttr))
- $("".someClass:data(myAttr='someValue'))
You can avoid the need for this, if you use custom data attributes, as and only as DOM attributes:
<div id=""test"" data-test=""value""></div>
..
$(""#test[data-test='value'])
But if you start using the .data() function, this is no longer possible in such a way:
<div id=""test""></div>
..
$(""#test"").data(""test"", ""value"")
$(""#test[data-test='value']) fails
Alternative:
$(""*"").filter(function() {
return $(this).data(""test"") === ""value"";
});
There is a already a plugin which implements this problem, which I would like to see included in $1.7 in some way...
http:plugins.jquery.com/project/dataSelector
Attachments (0)
Change History (11)
Changed May 22, 2011 07:27PM UTC by comment:1
keywords: | → 1.7-discuss |
---|
Changed May 22, 2011 08:33PM UTC by comment:2
description: | Provide a selector for .data(), similar to those of attributes: \ \ Example with attributes \ - $("".someClass[myAttr]) \ - $("".someClass[myAttr='someValue']) \ Likewise something for .data \ - $("".someClass:hasData(myAttr)) \ - $("".someClass:data(myAttr='someValue')) \ \ You can avoid the need for this, if you use custom data attributes, as and only as DOM attributes: \ <div id=""test"" data-test=""value""></div> \ .. \ $(""#test[data-test='value']) \ \ But if you start using the .data() function, this is no longer possible in such a way: \ <div id=""test""></div> \ .. \ $(""#test"").data(""test"", ""value"") \ $(""#test[data-test='value']) // fails \ \ Alternative: \ $(""*"").filter(function() { \ return $(this).data(""test"") === ""value""; \ }); \ \ There is a already a plugin which implements this problem, which I would like to see included in $1.7 in some way... \ http://plugins.jquery.com/project/dataSelector → Provide a selector for .data(), similar to those of attributes:\ \ Example with attributes\ - $("".someClass[myAttr])\ - $("".someClass[myAttr='someValue'])\ Likewise something for .data\ - $("".someClass:hasData(myAttr))\ - $("".someClass:data(myAttr='someValue'))\ \ You can avoid the need for this, if you use custom data attributes, as and only as DOM attributes:\ <div id=""test"" data-test=""value""></div>\ ..\ $(""#test[data-test='value'])\ \ But if you start using the .data() function, this is no longer possible in such a way:\ <div id=""test""></div>\ ..\ $(""#test"").data(""test"", ""value"")\ $(""#test[data-test='value']) // fails\ \ Alternative:\ $(""*"").filter(function() {\ return $(this).data(""test"") === ""value"";\ });\ \ There is a already a plugin which implements this problem, which I would like to see included in $1.7 in some way...\ http://plugins.jquery.com/project/dataSelector |
---|
-1, can be achieved with existing API; http://jsfiddle.net/rwaldron/AW2vj/
Changed May 23, 2011 01:04AM UTC by comment:3
-1, well, use the plugin
Changed May 23, 2011 05:07AM UTC by comment:4
-1, best as plugin
Changed May 23, 2011 05:04PM UTC by comment:5
description: | Provide a selector for .data(), similar to those of attributes:\ \ Example with attributes\ - $("".someClass[myAttr])\ - $("".someClass[myAttr='someValue'])\ Likewise something for .data\ - $("".someClass:hasData(myAttr))\ - $("".someClass:data(myAttr='someValue'))\ \ You can avoid the need for this, if you use custom data attributes, as and only as DOM attributes:\ <div id=""test"" data-test=""value""></div>\ ..\ $(""#test[data-test='value'])\ \ But if you start using the .data() function, this is no longer possible in such a way:\ <div id=""test""></div>\ ..\ $(""#test"").data(""test"", ""value"")\ $(""#test[data-test='value']) // fails\ \ Alternative:\ $(""*"").filter(function() {\ return $(this).data(""test"") === ""value"";\ });\ \ There is a already a plugin which implements this problem, which I would like to see included in $1.7 in some way...\ http://plugins.jquery.com/project/dataSelector → Provide a selector for .data(), similar to those of attributes: \ \ Example with attributes \ - $("".someClass[myAttr]) \ - $("".someClass[myAttr='someValue']) \ Likewise something for .data \ - $("".someClass:hasData(myAttr)) \ - $("".someClass:data(myAttr='someValue')) \ \ You can avoid the need for this, if you use custom data attributes, as and only as DOM attributes: \ <div id=""test"" data-test=""value""></div> \ .. \ $(""#test[data-test='value']) \ \ But if you start using the .data() function, this is no longer possible in such a way: \ <div id=""test""></div> \ .. \ $(""#test"").data(""test"", ""value"") \ $(""#test[data-test='value']) // fails \ \ Alternative: \ $(""*"").filter(function() { \ return $(this).data(""test"") === ""value""; \ }); \ \ There is a already a plugin which implements this problem, which I would like to see included in $1.7 in some way... \ http://plugins.jquery.com/project/dataSelector |
---|
-1,
probably a better written plugin: http://james.padolsey.com/javascript/a-better-data-selector-for-jquery/
Changed May 24, 2011 12:30AM UTC by comment:6
component: | unfiled → selector |
---|---|
priority: | undecided → low |
status: | new → open |
Changed May 24, 2011 10:22PM UTC by comment:7
-1, No new selectors.
Changed June 03, 2011 02:10PM UTC by comment:8
description: | Provide a selector for .data(), similar to those of attributes: \ \ Example with attributes \ - $("".someClass[myAttr]) \ - $("".someClass[myAttr='someValue']) \ Likewise something for .data \ - $("".someClass:hasData(myAttr)) \ - $("".someClass:data(myAttr='someValue')) \ \ You can avoid the need for this, if you use custom data attributes, as and only as DOM attributes: \ <div id=""test"" data-test=""value""></div> \ .. \ $(""#test[data-test='value']) \ \ But if you start using the .data() function, this is no longer possible in such a way: \ <div id=""test""></div> \ .. \ $(""#test"").data(""test"", ""value"") \ $(""#test[data-test='value']) // fails \ \ Alternative: \ $(""*"").filter(function() { \ return $(this).data(""test"") === ""value""; \ }); \ \ There is a already a plugin which implements this problem, which I would like to see included in $1.7 in some way... \ http://plugins.jquery.com/project/dataSelector → Provide a selector for .data(), similar to those of attributes:\ \ Example with attributes\ - $("".someClass[myAttr])\ - $("".someClass[myAttr='someValue'])\ Likewise something for .data\ - $("".someClass:hasData(myAttr))\ - $("".someClass:data(myAttr='someValue'))\ \ You can avoid the need for this, if you use custom data attributes, as and only as DOM attributes:\ <div id=""test"" data-test=""value""></div>\ ..\ $(""#test[data-test='value'])\ \ But if you start using the .data() function, this is no longer possible in such a way:\ <div id=""test""></div>\ ..\ $(""#test"").data(""test"", ""value"")\ $(""#test[data-test='value']) // fails\ \ Alternative:\ $(""*"").filter(function() {\ return $(this).data(""test"") === ""value"";\ });\ \ There is a already a plugin which implements this problem, which I would like to see included in $1.7 in some way...\ http://plugins.jquery.com/project/dataSelector |
---|
-1, Plugin.
Changed June 05, 2011 10:31PM UTC by comment:9
description: | Provide a selector for .data(), similar to those of attributes:\ \ Example with attributes\ - $("".someClass[myAttr])\ - $("".someClass[myAttr='someValue'])\ Likewise something for .data\ - $("".someClass:hasData(myAttr))\ - $("".someClass:data(myAttr='someValue'))\ \ You can avoid the need for this, if you use custom data attributes, as and only as DOM attributes:\ <div id=""test"" data-test=""value""></div>\ ..\ $(""#test[data-test='value'])\ \ But if you start using the .data() function, this is no longer possible in such a way:\ <div id=""test""></div>\ ..\ $(""#test"").data(""test"", ""value"")\ $(""#test[data-test='value']) // fails\ \ Alternative:\ $(""*"").filter(function() {\ return $(this).data(""test"") === ""value"";\ });\ \ There is a already a plugin which implements this problem, which I would like to see included in $1.7 in some way...\ http://plugins.jquery.com/project/dataSelector → Provide a selector for .data(), similar to those of attributes: \ \ Example with attributes \ - $("".someClass[myAttr]) \ - $("".someClass[myAttr='someValue']) \ Likewise something for .data \ - $("".someClass:hasData(myAttr)) \ - $("".someClass:data(myAttr='someValue')) \ \ You can avoid the need for this, if you use custom data attributes, as and only as DOM attributes: \ <div id=""test"" data-test=""value""></div> \ .. \ $(""#test[data-test='value']) \ \ But if you start using the .data() function, this is no longer possible in such a way: \ <div id=""test""></div> \ .. \ $(""#test"").data(""test"", ""value"") \ $(""#test[data-test='value']) // fails \ \ Alternative: \ $(""*"").filter(function() { \ return $(this).data(""test"") === ""value""; \ }); \ \ There is a already a plugin which implements this problem, which I would like to see included in $1.7 in some way... \ http://plugins.jquery.com/project/dataSelector |
---|
-1, Not only no new selectors, I feel like this is a particularly bad way to query the DOM generally. There's a :data selector baked into jQuery UI, if you want to use it. https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.core.js#L206
Changed June 06, 2011 03:30PM UTC by comment:10
description: | Provide a selector for .data(), similar to those of attributes: \ \ Example with attributes \ - $("".someClass[myAttr]) \ - $("".someClass[myAttr='someValue']) \ Likewise something for .data \ - $("".someClass:hasData(myAttr)) \ - $("".someClass:data(myAttr='someValue')) \ \ You can avoid the need for this, if you use custom data attributes, as and only as DOM attributes: \ <div id=""test"" data-test=""value""></div> \ .. \ $(""#test[data-test='value']) \ \ But if you start using the .data() function, this is no longer possible in such a way: \ <div id=""test""></div> \ .. \ $(""#test"").data(""test"", ""value"") \ $(""#test[data-test='value']) // fails \ \ Alternative: \ $(""*"").filter(function() { \ return $(this).data(""test"") === ""value""; \ }); \ \ There is a already a plugin which implements this problem, which I would like to see included in $1.7 in some way... \ http://plugins.jquery.com/project/dataSelector → Provide a selector for .data(), similar to those of attributes:\ \ Example with attributes\ - $("".someClass[myAttr])\ - $("".someClass[myAttr='someValue'])\ Likewise something for .data\ - $("".someClass:hasData(myAttr))\ - $("".someClass:data(myAttr='someValue'))\ \ You can avoid the need for this, if you use custom data attributes, as and only as DOM attributes:\ <div id=""test"" data-test=""value""></div>\ ..\ $(""#test[data-test='value'])\ \ But if you start using the .data() function, this is no longer possible in such a way:\ <div id=""test""></div>\ ..\ $(""#test"").data(""test"", ""value"")\ $(""#test[data-test='value']) // fails\ \ Alternative:\ $(""*"").filter(function() {\ return $(this).data(""test"") === ""value"";\ });\ \ There is a already a plugin which implements this problem, which I would like to see included in $1.7 in some way...\ http://plugins.jquery.com/project/dataSelector |
---|
-1, there are so many things you might or might not want this selector to handle
Changed June 07, 2011 06:53PM UTC by comment:11
milestone: | 1.next → 1.7 |
---|---|
resolution: | → wontfix |
status: | open → closed |
Closing per 1.7 roadmap meeting resolution
Nominating ticket for 1.7 discussion.