How some items can be group in separate optgroups
? Should be set in different JSON
objects? There is no example in select2
documentation. Any help or direction would be helpful.
Here is example code of select
population:
jQuery
code:
var data = [
{ id: 0, text: 'enhancement' },
{ id: 1, text: 'bug' },
{ id: 2, text: 'duplicate' },
{ id: 3, text: 'invalid' },
{ id: 4, text: 'wontfix' }
];
$(".js-example-data-array").select2({
data: data
});