如何允许/启用与jstree的链接?我想要能够点击箭头旁边的根,以扩大树(如果适用),但也想使文本链接?当我点击我的链接,什么都不会发生。例如,我会点击Google旁边的箭头来扩展树,但是点击Google这个词应该会带我去Google。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jsTree test</title>
<!-- 2 load the theme CSS file -->
<link rel="stylesheet" href="http://static.jstree.com/3.0.1/assets/dist/themes/default/style.min.css" />
</head>
<body>
<!-- 3 setup a container element -->
<div id="jstree">
<!-- in this example the tree is populated from inline HTML -->
<ul>
<li><a href="http://www.google.com">Google</a>
<ul>
<li id="child_node_1"><a href="http://www.yahoo.com">Yahoo</a></li>
<li><a href="http://www.outlook.com">Outlook</a></li>
</ul>
</li>
<li><a href="http://www.espn.com">Espn</a></li>
</ul>
</div>
<!-- 4 include the jQuery library -->
<script src="http://static.jstree.com/3.0.1/assets/jquery-1.10.2.min.js"></script>
<!-- 5 include the minified jstree source -->
<script src="http://static.jstree.com/3.0.1/assets/dist/jstree.min.js"></script>
<script>
$(function () {
// 6 create an instance when the DOM is ready
$('#jstree').jstree();
// 7 bind to events triggered on the tree
$('#jstree').on("changed.jstree", function (e, data) {
console.log(data.selected);
});
});
</script>
</body>
</html>发布于 2014-06-04 06:03:57
试试这个jsTree事件处理程序:
$('#jstree').on("select_node.jstree", function (e, data) { //open google in browser });我希望这就是你要找的。
https://stackoverflow.com/questions/24023018
复制相似问题