EASYUI Tree单击事件只执行一次,求助,急!

peomwang 2017-01-02 11:48:37
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<%@include file="/public/head.jspf"%>
<script type="text/javascript">
$(function(){
InitTreeData();
}) ;
function InitTreeData()
{
$('#tree').tree({
url:'<%=basePath%>trustlist.action',
checkbox:true,
parentField:'parentId',
lines:true,
animate:true,
onClick:function(node){
update();
},
onContextMenu: function(e, node){
e.preventDefault();
$('#tree').tree('select', node.target);
$('#mm').menu('show', {
left: e.pageX,
top: e.pageY
});
}
});
}
function remove()
{
var nodes = $('#tree').tree('getChecked');
var ids = '';
for(var i=0; i<nodes.length; i++){
if (ids != '') ids += ',';
ids += nodes[i].id;
//$('#tree').tree('remove',nodes[i].target);
}
$.post("demo01.ashx",{"ids":ids,"type":"del"},function(data){
InitTreeData();
});

}
function update()
{
var node = $('#tree').tree('getSelected');
if (node){
$('#p').panel({
title:'组织结构修改',
href:'<%=basePath %>getDeptByID.action?id='+node.id,
fit:true
});
}
}
function append()
{
var node = $('#tree').tree('getSelected');

$('#tree').tree('append',{
parent: (node?node.target:null),
data:
[
{
text:'new1',// -->txt-->DB
id:'1',
checked:true
}
]
});

}
</script>

</head>
<body class="easyui-layout">
<div id="mm" class="easyui-menu" style="width: 120px;">
<div onclick="append()" iconcls="icon-add">
添加节点</div>
<div onclick="remove()" iconcls="icon-remove">
删除节点</div>
<div onclick="update()" iconcls="icon-edit">修改节点</div>
</div>
<div data-options="region:'center',border:false" >
<div id="p">
</div>
</div>
<div data-options="region:'west',border:false,split:true" style="width:200px;overflow: hidden; ">
<div class="easyui-panel" title="组织机构"
style="padding:10px;"
data-options="fit:true,border:false">
<ul id="tree">
</ul>
<br/>
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'">添加机构</a>
</div>
</div>
</body>
</html>

如图,单击左侧tree节点,能在右侧显示,但是只能单击一次,再单击就无效果,怎么解决啊,困扰好久了,求各位大神帮忙解决。
...全文
176 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
antchow- 2017-01-03
  • 打赏
  • 举报
回复
你是不是在点击之前没有清空掉右边的容器
peomwang 2017-01-02
  • 打赏
  • 举报
回复
引用 1 楼 showbo 的回复:
remove掉节点就好了,干嘛要重新初始化树。。 remove target Remove a node and it's children nodes, the target parameter indicate the node DOM object.
那个不是重点,那个是我从网上找的右键菜单的方法,后续会改,我问题是单击节点显示右侧内容,但是只有一次效果,再单击其他节点就不能显示了
Go 旅城通票 2017-01-02
  • 打赏
  • 举报
回复
remove掉节点就好了,干嘛要重新初始化树。。 remove target Remove a node and it's children nodes, the target parameter indicate the node DOM object.

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧