我有一个json如下;
var jsonRoles = {"roles": [
{"roleId": 1, "roleName": "Admin", "roleDesc": "This is an Admin"},
{"roleId": 2, "roleName": "Manager", "roleDesc": "This is a Manager role"},
{"roleId": 3, "roleName": "User", "roleDesc": "This is a user role"}
]
};
我想以编程方式将数据插入到 dnd 源中,如下所示;
var rolesItems = new Source("roleNode", { accept: [ "roleName"] });
rolesItems .insertNodes(false, [
{ data: "Admin", type: [ "roleName" ] },
{ data: "Manager", type: [ "roleName" ] },
{ data: "User", type: [ "roleName" ] }
]);
rolesItems .forInItems(function(item, id, map){
domClass.add(id, item.type[0]);
});
我该如何执行任务?任何的想法?