使用jQuery插件select2 multlectlect如何选择一个组及其所有子组件,但在未选择组时允许选择多个子组件?您将在下面找到一个允许选择组的jsfiddle,但一次只能选择一个子组。对此的任何帮助将不胜感激。
jsfiddle select2 multiple - http://jsfiddle.net/jcUUG/145/
HTML CODE:
<input type='hidden' id='select'>
JS CODE:
$(function () {
var select2_ary = [];
select2_ary.push(
{id: 'numbers', text: 'numbers',
children: [
{id: "numbers", text: "1"},
{id: "numbers", text: "2"},
{id: "numbers", text: "3"},
{id: "numbers", text: "4"},
{id: "numbers", text: "5"}
]
},
{id: 'letters', text: 'letters',
children: [
{id: "letters", text: "A"},
{id: "letters", text: "B"},
{id: "letters", text: "C"},
{id: "letters", text: "D"},
{id: "letters", text: "E"}
]
}
);
$("#select").select2({
placeholder: "Select",
data: select2_ary,
multiple: true,
width: "300px"
});
});