jquery.selectBoxIt.js icon indicating copy to clipboard operation
jquery.selectBoxIt.js copied to clipboard

dynamically add optgroup support?

Open ComboStyle opened this issue 10 years ago • 6 comments

I've seen how to add options dynamically but how can i add optgroups dynamically? is there a way? even if not a convenient way maybe a more 'hacky' one?

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/4050366-dynamically-add-optgroup-support?utm_campaign=plugin&utm_content=tracker%2F23157&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F23157&utm_medium=issues&utm_source=github).

ComboStyle avatar Aug 26 '14 11:08 ComboStyle

I think only like a string .add("html")

i-have-no-name avatar Aug 26 '14 11:08 i-have-no-name

it ignores it :(

ComboStyle avatar Aug 26 '14 12:08 ComboStyle

try to do .refresh() after add

i-have-no-name avatar Aug 26 '14 12:08 i-have-no-name

maybe im doing something wrong?: (ignore the ! mark its just that github wont render it without it) selectbox.data("selectBox-selectBoxIt").add('<!optgroup label="Swedish Cars">'); selectbox.data("selectBox-selectBoxIt").add({ value: index, text: form.title }); selectbox.data("selectBox-selectBoxIt").add('<!/optgroup>'); selectbox.data("selectBox-selectBoxIt").refresh();

ComboStyle avatar Aug 26 '14 12:08 ComboStyle

var select = $("select").data("selectBox-selectBoxIt"); select.add("optgroup option text option optgroup") select.refresh();

i-have-no-name avatar Aug 26 '14 12:08 i-have-no-name

thanks it works, only drawback is that i have to parse by myself all my options and write them as html which is a bit of a pain. P.S the refresh is not needed

ComboStyle avatar Aug 26 '14 12:08 ComboStyle

@kfir124 @i-have-no-name

Hello,

I am also having the same issue. May i know how to add the optgroup label? Is it using HTML strings? Can you provide an example for this? Thank you so much.

bluesky88 avatar Mar 11 '15 17:03 bluesky88