这个数据数据没有绑定,可以任意设置
presentProfile = Object {authenticateCode: null,frontendPermission:
Array(3)
0:"administrator"
1:"author"
2:"contributor" }
jQuery.each(presentProfile.frontendPermission, function (index, data) {
jQuery("#bis_frontend_display_roles").select2("val", data);
});
答案 0 :(得分:1)
请尝试以下代码:
var presentProfile = {
authenticateCode: null,
frontendPermission:[{id:0, text:"administrator"},{id:1, text:"author"},{id:2, text:"contributor"}]
} ;
jQuery("#bis_frontend_display_roles").select2({data: presentProfile.frontendPermission});