Jquery 如何向特定jsTree节点添加工具提示

Jquery 如何向特定jsTree节点添加工具提示,jquery,jstree,Jquery,Jstree,我的节点似乎覆盖了另一个区域,但我似乎无法正确地控制它。如果你知道怎么做,那么我也会接受这个解决方案。鉴于许多节点字符串可能非常长,因此最好向节点添加工具提示 my script... <script type="text/javascript"> $(document).ready(function(){ $('#jstree').jstree({ plugins: ["themes","html_data", "state"], 'core' : {

我的节点似乎覆盖了另一个区域,但我似乎无法正确地控制它。如果你知道怎么做,那么我也会接受这个解决方案。鉴于许多节点字符串可能非常长,因此最好向节点添加工具提示

my script...
<script type="text/javascript">
$(document).ready(function(){
$('#jstree').jstree({

    plugins: ["themes","html_data", "state"],
    'core' : {
         'themes' : {
        'theme' : "apple",
        'dots' : true,
        'icons' : false
    },
        'data' : jsonTreeData
    }
    }).bind("select_node.jstree", function (e, data) {
     var href = data.node.a_attr.href;
     var parentId = data.node.a_attr.parent_id;
     if(href == '#')
     return '';

     window.open(href);

});
$('#jstree').slimScroll({
    height: '400px'
});
我的脚本。。。
$(文档).ready(函数(){
$('#jstree').jstree({
插件:[“主题”、“html_数据”、“状态”],
“核心”:{
“主题”:{
'主题':“苹果”,
“点”:没错,
“图标”:false
},
“数据”:jsonteedata
}
}).bind(“select_node.jstree”,函数(e,数据){
var href=data.node.a_attr.href;
var parentId=data.node.a\u attr.parent\u id;
如果(href=='#')
返回“”;
window.open(href);
});
$('#jstree').slimScroll({
高度:“400px”
});


要将工具提示添加到节点,您可以在准备数据时通过添加
标题来使用\u attr属性。您也可以在相同的属性中使用超链接

您可以按如下方式使用json数据:

var jsondata = [
    { "id": "ajson1", "parent": "#", "text": "Simple root node", "a_attr": {href:'http://example1.com', title:'Simple root node tooltips'} },
    { "id": "ajson2", "parent": "#", "text": "Root node 2", "a_attr": {href:'http://example2.com', title:'Root node 2 tooltips'} },
    { "id": "ajson3", "parent": "ajson2", "text": "Child 1",  "a_attr": {href:'http://example3.com', title:'Child 1 tooltips'} },
    { "id": "ajson4", "parent": "ajson2", "text": "Child 2",  "a_attr": {href:'http://example4.com', title:'Child 2 tooltips'} }
];

剩下的就用它了。你可以在中查看下面简单而完整的工作示例。

你也可以添加html代码吗?@Murali--我使用了省略号,所以我现在不太关心文本的宽度或过多…另外,我使用的是滚动条,所以最好只使用工具提示。html非常混乱,因为它有所有的内联元素…但我会发布它
var jsondata = [
    { "id": "ajson1", "parent": "#", "text": "Simple root node", "a_attr": {href:'http://example1.com', title:'Simple root node tooltips'} },
    { "id": "ajson2", "parent": "#", "text": "Root node 2", "a_attr": {href:'http://example2.com', title:'Root node 2 tooltips'} },
    { "id": "ajson3", "parent": "ajson2", "text": "Child 1",  "a_attr": {href:'http://example3.com', title:'Child 1 tooltips'} },
    { "id": "ajson4", "parent": "ajson2", "text": "Child 2",  "a_attr": {href:'http://example4.com', title:'Child 2 tooltips'} }
];