首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JSTree链接不工作

JSTree链接不工作
EN

Stack Overflow用户
提问于 2014-06-03 19:06:42
回答 1查看 1.4K关注 0票数 0

如何允许/启用与jstree的链接?我想要能够点击箭头旁边的根,以扩大树(如果适用),但也想使文本链接?当我点击我的链接,什么都不会发生。例如,我会点击Google旁边的箭头来扩展树,但是点击Google这个词应该会带我去Google。

代码语言:javascript
复制
<!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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-06-04 06:03:57

试试这个jsTree事件处理程序:

代码语言:javascript
复制
$('#jstree').on("select_node.jstree", function (e, data) { //open google in browser });

我希望这就是你要找的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24023018

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档