Chandusangale / dropdown-check-list

Automatically exported from code.google.com/p/dropdown-check-list
1 stars 0 forks source link

CSS Class support for items in the drop down list #196

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
** What steps will reproduce the problem?
It's not really a problem, but it would be a 'good-to-have' thing, where 
instead of just having custom styles on each option, one can also apply this 
styling through CSS classes

** What is the expected output? What do you see instead?
The labels created by the dropdown check list plugin will have the same classes 
applied to the options in the select menu

** What is your environment?
-- DropDownCheckList version: 1.4
-- jQuery version: 1.6.2
-- jQuery UI version: 1.8.13
-- Browser and version: All

** Please provide any additional information below/Please attach sample
Normal application of styling:
<select id='test' multiple='multiple'>
<option value='1' style='color:green'>option 1</option>
<option value='2' style='color:red'>option 2</option>
<option value='3' style='color:blue'>option 3</option>
</select>

Requested styling method:
<style type='text/css'>
.greenoption{
 color: green;
}
.redoption{
color: red;
}
.blueoption{
color: blue;
}
</style>
<select id='test' multiple='multiple'>
<option value='1' class='greenoption'>option 1</option>
<option value='2' class='redoption'>option 2</option>
<option value='3' class='blueoption'>option 3</option>
</select>

I have temporarily added this "feature" to my solution by editing the 
dropdownchecklist _createDropItem function by adding an 'optClass' parameter, 
which is passed to it from the _appendOption method by using: var optClass = 
option.attr('class');

Then in the _createDropItem method I added          
if ( optClass != null) label.addClass(optClass);

I would suggest to add this functionality since it is very useful when styling 
will need to be done from another developer (as is my case)

Original issue reported on code.google.com by gianni...@gmail.com on 22 Jul 2011 at 12:41

GoogleCodeExporter commented 9 years ago
Sorry, I meant to make this an 'Enhancement' not a 'Defect'!

Original comment by gianni...@gmail.com on 22 Jul 2011 at 12:42

GoogleCodeExporter commented 9 years ago
This sounds very reasonable.  If someone goes to the trouble of marking the 
class on the individual <option>, then carrying that class into the generated 
item makes perfect sense.
I will try to incorporate your change into the next release.

Original comment by womohun...@ittrium.com on 22 Jul 2011 at 6:23

GoogleCodeExporter commented 9 years ago
Thanks for your reply! I found the fix quite useful in my case so I thought I'd 
share! Well done on a great plug-in btw, this saved me a lot of time!

Original comment by gianni...@gmail.com on 25 Jul 2011 at 8:18