我使用select2
代替搜索框。在select2多选中加载值
这里我使用的加载这样
$("#countries").select2({
multiple: true,
tags:["India", "Japan", "Australia","Singapore"],
tokenSeparators: [","]
});
当我按下保存按钮,它们被正确地提交到服务器,现在这里的问题是,当 我想修改该国领域的国家价值观保存到服务器后,我如何将保存的值加载到国家字段。
这是我从服务器获取数据
$.getJSON('/dataprovider?data=fetchCountriesForm', function(opts) {
//the opts here contains the json values of the countries.
//what code should be written here to load the values in $('#countries).select2();
//user can add some more countries or can remove the previously added countries.
}
我知道这是古老的,所以原谅我,但这似乎不适用于2维数组?我可以加载诸如('dog','cat','mouse')但不是('1':'Dog','2':'Cat','3':'Mouse')的值。你能做到吗? – SBB