hernansartorio / jquery-nice-select

A lightweight jQuery plugin that replaces native select elements with customizable dropdowns.
http://jqueryniceselect.hernansartorio.com
957 stars 286 forks source link

does not show optgroup #22

Open amin101 opened 8 years ago

amin101 commented 8 years ago

I have a select menu containing items like :

 <select>
  <optgroup label="Swedish Cars">
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
  </optgroup>
  <optgroup label="German Cars">
    <option value="mercedes">Mercedes</option>
    <option value="audi">Audi</option>
  </optgroup>
</select> 

but only options are displaying in list and no optgroup label is showing

antoniolite commented 7 years ago

Same problem here. Trying to get it work for a couple of hours...

Were you able to solve it?

amin101 commented 7 years ago

no unfortunately

cdowning commented 7 years ago

I've been troubleshooting this and I finally got it. If you add these changes to the JS file (https://github.com/hernansartorio/jquery-nice-select/pull/18/files). Then on your html, add a count on each optgroup add data-i="1", etc. I included a jsbin link below.

jsbin link: http://jsbin.com/riguvaj/1/edit?html,css,js,output

RAFDigital101 commented 6 years ago

thanks, but would be nice to use UL LI not div span ;)

mehulsharma01 commented 4 years ago

https://jsfiddle.net/sharmamehu01/pxsmqu8y/ maybe this will help you thank me later.

KongCheeHong commented 3 years ago

https://jsfiddle.net/sharmamehu01/pxsmqu8y/ maybe this will help you thank me later.

Thanks, this is what I looking for.