How to use a llink

116 views
Skip to first unread message

Eric Krenz

unread,
Jul 17, 2014, 11:31:26 AM7/17/14
to jst...@googlegroups.com
I'm wondering if anyone knows how to use each node as a hyperlink.

<div id="jstree" >
    @OrgTree(Model, 1)
</div>
   
@helper OrgTree(IEnumerable
<CheckListItem_Master> nodes, int? parentId) {
    if (nodes.Any(n => n.HigherItemID == parentId))
    {
   
<ul>
        @foreach (var node in nodes.Where(n => n.HigherItemID == parentId))
        {
           
<li>
                @Html.ActionLink(node.Name, "Details", new { id = node.CheckListItemID })
                @OrgTree(nodes, node.CheckListItemID)
           
</li>
        }
   
</ul>
    }
}


<script type="text/javascript">


    $i
('#jstree').jstree({
       
"core": {
           
"themes": {
               
"icons": false
           
}
       
},
   
});


</script>

How can I make it redirect to the same location that the action-link goes to above?

I found this tidbit:

.on("select_node.jstree", function (e, data){
        document.location = data.instance.get_node(data.node, true).children('2').attr('<your link>');
    });

But I'm not sure how to get the same functionality out of it as before.

Thanks,
-Eric

Ivan Bozhanov

unread,
Jul 17, 2014, 12:13:57 PM7/17/14
to jst...@googlegroups.com
on('select_node.jstree', function (e, data) {
  window.location = data.node.a_attr.href;
})

Best regards,
Ivan

Eric Krenz

unread,
Jul 17, 2014, 12:17:45 PM7/17/14
to jst...@googlegroups.com
Thank you again Ivan.

I was able to get it working with
.on("select_node.jstree", function (e, data){
        document.location = "details/"+data.instance.get_node(data.node, true).attr("id");
but your solution is much more elegant.

Your support is appreciated
-Eric
Reply all
Reply to author
Forward
0 new messages