Opened 10 years ago
Closed 10 years ago
#12397 closed feature (wontfix)
Allow passing a function to .data() as an each style setter.
Reported by: | gnarf | Owned by: | gnarf |
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | data | Version: | 1.8.0 |
Keywords: | 1.9-discuss | Cc: | |
Blocked by: | Blocking: |
Description (last modified by )
Example Usage:
jQuery( ".button" ).data(function( index, data ) { if ( data.href ) { // <div class="button" data-href="/"> } if ( data.confirm ) { // etc } jQuery( this ).button(); // return value discarded, data must remain the same object for other uses });
The code would be a pretty simple each, and it would let you quickly inspect/alter the data object on an entire jQuery collection.
The same could NOT be done for the elems.data( "key", fn )
signature, because you want to set that key to a function...
Pull Request: https://github.com/jquery/jquery/pull/910
Change History (12)
comment:1 Changed 10 years ago by
Description: | modified (diff) |
---|
comment:3 Changed 10 years ago by
Description: | modified (diff) |
---|
comment:4 Changed 10 years ago by
Component: | unfiled → data |
---|---|
Keywords: | 1.9-discuss added |
Owner: | set to gnarf |
Status: | new → assigned |
comment:5 Changed 10 years ago by
Type: | enhancement → feature |
---|
Bulk change from enhancement to feature.
comment:6 Changed 10 years ago by
Priority: | undecided → low |
---|
comment:8 Changed 10 years ago by
-1, I think this is just too viscerally of an odd duck to add. It's sort of a function setter, sort of a getter... It's basically with (dataObj) { }
- I don't think we need it.
comment:9 Changed 10 years ago by
-1, It's a unique signature and there is already a way to do this, so making an exception is less compelling.
comment:11 Changed 10 years ago by
+1, Feel so dirty, voting on my own idea. It's a connivence method for plugin authors really. Or people doing large amounts of editing of the data object. I won't be offended if we pass on it though.
comment:12 Changed 10 years ago by
-1, complexity of the new signature is greater than the low cost of ad-hoc manual implementation
comment:13 Changed 10 years ago by
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
Safe to say this ticket is open.