Skip to content
This repository has been archived by the owner on May 16, 2021. It is now read-only.

Classes on checkboxes, radio buttons, and selects don't get pulled onto the wrapping divs #355

Open
roubaobaozi opened this issue Sep 9, 2013 · 3 comments
Labels

Comments

@roubaobaozi
Copy link

div.selector, div.checker, div.radio don't take on the classes of the inputs/selects they wrap, but often adding a class is necessary for certain styling.

I wrote this (all inputs, selects and textareas within .uniform have uniform() run on them):

$('.uniform input:checkbox[class]').each(function() {
var checkboxClasses = $(this).attr('class');
$(this).parent().parent('div.checker').addClass(checkboxClasses);
});
$('.uniform input:radio[class]').each(function() {
var radioClasses = $(this).attr('class');
$(this).parent().parent('div.radio').addClass(radioClasses);
});
$('.uniform select[class]').each(function() {
var selectClasses = $(this).attr('class');
$(this).parent('div.selector').addClass(selectClasses);
});

Which does the job for me. I don't know if there's a better way that could be written. Just thought someone might like it, or know how to .. make this available for all uniform.js users.

Hope this is useful.

Cheers

@LeeBurton
Copy link

I have also come across this problem and have had to implement a hack. But the problem is that sometimes you want classes to be inherited, and sometimes you don't... If they are classes used for styling, it would be important to inherit them. If the classes are used as selectors to implement some functionality, it may not be a good idea... so how do you decide?

One solution I implemented was to take a list of all classes and extract a list of forbidden functional classes using regular expressions, then adding those classes to the wrapper

. I don't see any other way of getting around this...

@ghost
Copy link

ghost commented Nov 26, 2013

I've started with a rewrite of Uniform to address many concerns. This last comment in particular poses a challenge with my new scheme - I plan on copying all classes to the wrapper. I figure that if you want to style the element, your CSS would use input.some-class instead of .some-class. If you are targeting an element, you could use $('input.some-class') or $('.some-class').not('.uniformjs').

@fidian
Copy link
Collaborator

fidian commented Nov 26, 2013

Sorry - posted as the wrong user. Look up fidian if you want to contact me about the Uniform rewrite.

@shehi shehi added the triage label Aug 24, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants