Active
Project:
Jquery Dropdown
Version:
6.x-1.2
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
26 Oct 2011 at 22:19 UTC
Updated:
26 Oct 2011 at 23:34 UTC
I the current javascript nukes optgroups by passing through each option element without regart to optgroupings...
here's an updated script snippet that should help:
in place of
$(this).find("option").each(function(){
var this_class="jquery_dropdown_option";
if($(this).val()==select_default_value)
this_class += " jquery_dropdown_option_selected";
output += '<li class="'+this_class+'"><a href="#" class="'+select_id+'" rel="'+$(this).val()+'">'+$(this).text().replace(/ /g, ' ')+'</a></li>';
c++;
});
put
//build <ul> list here
if($(this).find("optgroup").length){
$(this).find("optgroup").each(function(){
output += '<li class="jquery_dropdown_optgroup_label">'+$(this).attr('label')+'</li>';
$(this).find("option").each(function(){
var this_class="jquery_dropdown_option";
if($(this).val()==select_default_value)
this_class += " jquery_dropdown_option_selected";
output += '<li class="'+this_class+'"><a href="#" class="'+select_id+'" rel="'+$(this).val()+'">'+$(this).text().replace(/ /g, ' ')+'</a></li>';
c++;
});
});
}else{
$(this).find("option").each(function(){
var this_class="jquery_dropdown_option";
if($(this).val()==select_default_value)
this_class += " jquery_dropdown_option_selected";
output += '<li class="'+this_class+'"><a href="#" class="'+select_id+'" rel="'+$(this).val()+'">'+$(this).text().replace(/ /g, ' ')+'</a></li>';
c++;
});
}
the latter checks for optgroups... sloppy copy/paste, but gets the job done.
//TODO: breakout the existing code into a function and run it by function name rather than copy/pasting