easyui 点击树(tree)的节点文字展开或关闭节点
单击:不是很完美,有时需要两下;
双击:很完美。
$('#nav').tree({
url: '/menu',
lines: false,
onLoadSuccess: function(node, data) {
var _this = this;
if (data) {
$(data).each(function(index, value) {
$(_this).iconCls = data.iconcls;
if (_this.state == 'closed') {
$(_this).tree('collapsAll');
}
});
}
},
onClick: function(node) {
$(this).tree(node.state === 'closed' ? 'expand' : 'collapse', node.target);
node.state = node.state === 'closed' ? 'open' : 'closed';
if (node.url) {
if ($('#tabs').tabs('exists', node.text)) {
$("#tabs").tabs('select', node.text)
} else {
$('#tabs').tabs('add', {
title: node.text,
closable: true,
iconCls: node.iconCls,
href: node.url + '.jsp',
})
}
}
},
onDblClick: function(node) {
$(this).tree(node.state === 'closed' ? 'expand' : 'collapse', node.target);
node.state = node.state === 'closed' ? 'open' : 'closed';
}
});