2014-06-03 3 views
0

Как вы разрешаете/разрешаете связывание с jstree? Я хочу, чтобы можно было щелкнуть стрелку рядом с корнем, чтобы развернуть дерево (если это применимо), но также хотите, чтобы текст был привязан? Когда я нажимаю на мои ссылки, ничего не происходит. Например, я бы нажал стрелку рядом с Google, следует развернуть дерево, но нажав на слово Google, я должен отвезти меня в Google.JSTree ссылки не работают

<!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> 

ответ

0

попробовать этот jsTree обработчик события:

$('#jstree').on("select_node.jstree", function (e, data) { //open google in browser }); 

Я надеюсь, что это то, что вы ищете.

Смежные вопросы