【发布时间】:2016-01-30 16:29:18
【问题描述】:
在select2“加载远程数据”example 响应 json 包含比“加载数组数据”example2 更多的信息。
是否可以加载包含数组数据的本地json文件如下图 并使用 select2 使所有键可选择/可搜索,例如文本,文本2和文本3?
var data = [
{
id: 0,
text: 'enhancement',
text2: 'text2',
text3: 'text3'
},
{
id: 1,
text: 'bug',
text2: 'text2',
text3: 'text3'
},
{
id: 2,
text: 'duplicate',
text2: 'text2',
text3: 'text3'
},
{
id: 3,
text: 'invalid',
text2: 'text2',
text3: 'text3'
},
{
id: 4,
text: 'wontfix',
text2: 'text2',
text3: 'text3'
}
];
$(".js-example-data-array").select2({
data: data
})
<select class="js-example-data-array"></select>
【问题讨论】:
标签: javascript jquery json jquery-select2