1、先上代码:
createUserFunction = {
"label": "新增用户", "action": function (obj) {
var inst = jQuery.jstree.reference(obj.reference);
var clickedNode = inst.get_node(obj.reference);
if(clickNode.id ==-1){
toaster.pop({
"type":"error",
"title":"提示信息",
"body":"不能在根节点上添加用户",
“useCloseButton”:true,
"timeout:3000
})
}else{
$scope.addUser(clickedNode);
}
}
}
$scope.treeConfig = {
'version': 1, 'plugins': ['types', "contextmenu"], 'types': {
'default': {
'icon': 'fa fa-folder'
}, 'html': {
'icon': 'fa fa-file-code-o'
}, 'svg': {
'icon': 'fa fa-file-picture-o'
}, 'css': {
'icon': 'fa fa-file-code-o'
}, 'img': {
'icon': 'fa fa-file-image-o'
}, 'js': {
'icon': 'fa fa-file-text-o'
}
}, "contextmenu": {
"items": {
"create": createUserFunction, "add": addDeptFunction, "delete": deleteDeptFunction
}
}
};
2、我是用的jsTree控件,构造一棵部门树,在节点上右键可以有菜单,但是根节点因为一些原因不允许操作,所以做了限制。现在出现的问题是:
当我在根节点上操作的时候不会立即弹框提示,可是要重复好几次,才会有反应,看图:
3、还请大神指点迷津!