开发者

How to create a new ID for the new added node?

I can normally get the ID of the default tree nodes but my problem is onCreate then jsTree will add a new node but it doesn't have an ID. My question is how can I add an ID to the newly created tree node?

What I'm thinking to do is adding the ID HTML attribute to the newly created tree node but how?

I need to get the ID of all of the nodes because it will serve as a reference for the node's respective div storage.

HTML code:

<div class="demo" id="demo_1">
<ul>
    <li id="ph开发者_如何学JAVAtml_1" class="file"><a href="#"><ins>&nbsp;</ins>Root node 1</a></li>
    <li id="phtml_2" class="file"><a href="#"><ins>&nbsp;</ins>Root node 2</a></li>
</ul>
</div>

JS code:

$("#demo_1").tree({
    ui : {
        theme_name : "apple"
    },
    callback : {
        onrename : function (NODE, TREE_OBJ) {
            alert(TREE_OBJ.get_text(NODE));
            alert($(NODE).attr('id'));
        }
    }
});

Cheers, Mark


If you have access to the node you should be able to add the ID by yourself:

$(NODE).attr('id',id_value);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜