scottdarby / Stylish-Select

*No longer maintained* A cross-browser, accessible alternative to the standard form select element which can be fully customised with CSS
122 stars 50 forks source link

Inherit css class from original select element #6

Closed chrislp closed 13 years ago

chrislp commented 14 years ago

Adding $containerDiv.addClass($input.attr('class')); in line 68 would add the original select element's css class to the newly created element. I think that would be very useful - any opinions?

justbeez commented 14 years ago

I would disagree with this being the default behavior for a number of reasons. Here are a few off the top of my head:

  1. I use a class to designate select, so if that class is copied to the new element I can no longer find my original select elements by class.
  2. This could break the styling. For example, I don't initialize Stylish Select for certain user agents (such as iPhone, because of the unique small-screen implimentation they have). So I might want to style the original select in those other UAs.
  3. At the time of initialization, other scripts could be adding/removing classes on elements that I might not want to persist permenately on the new list.

While this could be added as a configuration option, I'm not sure what the use case is . . . could you elaborate?

My 2 cents is that it would be far more useful to be able to specify a list of classes in the configuration options that are automatically applied to the new elements. For example: $('#element').sSelect({defaultClasses: 'myCalss yourClass'});

Thoughts?

chrislp commented 14 years ago

Your points are right but there's one thing I'd disagree. If I write css for the select and plan to use sSelect it should work with the select-element and sSelect's container-div. However your proposal is most flexible so I give it a definite thumbs up!