Bug Tracker

Opened 14 years ago

Closed 13 years ago

#4630 closed enhancement (wontfix)

Add radioClass method

Reported by: brandon Owned by: brandon
Priority: low Milestone: 1.next
Component: attributes Version: 1.3.2
Keywords: needsreview Cc:
Blocked by: Blocking:


radioClass method (inspired by Ext Core) adds a class to one element and removes it from its siblings. Attached is a patch to include radioClass into jQuery. This creates a dependency of the selectors module to the attributes module which didn't exist before. I didn't use the .siblings() method so as not to create another dependency on traversing.

Attachments (1)

radioClass.diff (1.8 KB) - added by brandon 14 years ago.
radioClass method

Download all attachments as: .zip

Change History (15)

Changed 14 years ago by brandon

Attachment: radioClass.diff added

radioClass method

comment:1 Changed 14 years ago by bganicky

Definitely good addition. I need this too often not to appreciate such a method.


comment:2 Changed 14 years ago by memiux

Yeap, I agree too

comment:3 Changed 14 years ago by scrufus


I would use this a lot.

comment:4 Changed 14 years ago by paul.irish

Would these two then be equivalent?


Even though Ext may go with radioClass, it doesn't specifically target radio's which can appear misleading; siblingClass() would be more logical to me.

But on the whole, it doesn't seem to be enough of an improvement to deserve it's own syntactic sugar. This would also be the only attribute manipulation method that assumes a specific DOM relationship. A bit odd to me.


comment:5 Changed 14 years ago by ajpiano

not so sure this needs to be in core (though it seem some people like it). the name is certainly misleading, and i think that if something like this is going to go in, it way as well work natively to apply this behaviour on checkboxes, which at present wouldn't really be manipulated by this enhancement.

comment:6 Changed 14 years ago by bbonifield

I'm in agreement with paul.irish in both the naming and usefulness. The method would only be useful when dealing with exclusive classes in sibling relationships.

If you wanted to add something like this, I'd would say it is more valuable to have some flexibility.

Assuming you had

<div id="parent">
    <li class="active">1</li>

Something like...

$("#parent ul:last li:first").exclusiveClass('active', $("#parent"));

Where the second argument would be the scope that you should maintain exclusiveness within (perhaps making it so that the default scope is within the direct parent).


comment:7 Changed 14 years ago by cowboy

I agree with paul_irish completely.

comment:8 Changed 14 years ago by redsquare

I agree with my chums from #jquery.

I'd rather see these type of extension functions go into an 'optional' lib which would be available to download alongside the core. Lets keep the core lean and mean.

comment:9 Changed 14 years ago by eduardo

It's definitely useful.


comment:10 Changed 13 years ago by dmethvin

Component: unfiledattributes

comment:11 Changed 13 years ago by Rick Waldron

Milestone: 1.5
Priority: majorlow
Status: newopen

Needs review/attention

comment:12 Changed 13 years ago by dmethvin

Keywords: needsreview added
Milestone: 1.51.next

comment:13 Changed 13 years ago by doublerebel

To have the same behavior as the Ext method, radioClass must also take an array of classes, as in my little plugin here:


Interestingly, this ticket was filed (and various radioclass blog posts were written) about the same time I created that. I think radioClass would definitely see use.

comment:14 Changed 13 years ago by Rick Waldron

Resolution: wontfix
Status: openclosed

Without a public repo, unit tests or docs, it's hard to support something that already seems easily accomplished with existing core methods - as noted by paul.irish


Note: See TracTickets for help on using tickets.