JSTree 拖放检查回调
JSTree Drag n Drop Checking Callback
我正在使用 JSTree,它被证明是一个很棒的工具。
使用拖放插件我遇到了这个:
当我将文件拖到 valid_children 不允许文件的文件夹时,它不会显示红叉,但也不允许放置(如 valid_children 预期行为)。为了更好的用户体验,我需要在父节点的 valid_children 不包含被拖动节点的类型时显示十字。这是我正在寻找的示例:
有什么想法吗?
找到解决方案,它与 what I've found in Whosebug
略有不同
- 在 "types" 配置上明确定义您的 valid_childrens。
- 将check_callback上的参数添加到函数(operation, node, node_parent, node_position, more)
- 添加到 check_callback:
switch (operation) {
case 'move_node':
return ($.inArray(node.type, this.get_rules(more.ref).valid_children) != -1);
default:
return true;
}
我正在使用 JSTree,它被证明是一个很棒的工具。 使用拖放插件我遇到了这个:
当我将文件拖到 valid_children 不允许文件的文件夹时,它不会显示红叉,但也不允许放置(如 valid_children 预期行为)。为了更好的用户体验,我需要在父节点的 valid_children 不包含被拖动节点的类型时显示十字。这是我正在寻找的示例:
有什么想法吗?
找到解决方案,它与 what I've found in Whosebug
略有不同- 在 "types" 配置上明确定义您的 valid_childrens。
- 将check_callback上的参数添加到函数(operation, node, node_parent, node_position, more)
- 添加到 check_callback:
switch (operation) {
case 'move_node':
return ($.inArray(node.type, this.get_rules(more.ref).valid_children) != -1);
default:
return true;
}