I'm looking for a way to highlight the last leaf node that was clicked. We are using the navigateurlkey on our leafnodes to fire some jquery. Is there an easy way to change the background color of the anchor tag until a new anchor tag within the tree is clicked?
Hello Clifford,Thank you for sharing your experience with the tree with the whole community. The code seems to be ok.
After initial testing. It turns out that the function needed to be expanded. The tree is three levels, 2 parent, and 1 leaf. I am not a jquery expert but this is what I got working. If there is a better way, please let me know.
$(".ui-igtree-expander").unbind("click"); $('.ui-igtree-parentnode img').click(function (event) { if($('#Tree1').igTree("isExpanded", $(this).parent())) { $('#Tree1').igTree('collapse', $(this).parent()); } else { $('#Tree1').igTree('expand', $(this).parent()); }
});
$('.ui-igtree-parentnode span').click(function (event) { if($('#Tree1').igTree("isExpanded", $(this).parent())) { //debugger; $('#Tree1').igTree('collapse', $(this).parent()); } else { //debugger; $('#Tree1').igTree('expand', $(this).parent()); }
$('.ui-igtree-parentnode a').click(function (event) { if($('#Tree1').igTree("isExpanded", $(this).parent())) { //debugger; $('#Tree1').igTree('collapse', $(this).parent()); } else { //debugger; $('#Tree1').igTree('expand', $(this).parent()); }
Thank you both for your help. Both were easy solutions to my issues and everything works as hoped for now.
Cliff
This is actually rather easy to do. Here's how:
$('.ui-igtree-parentnode').click(function (event) {
$('#treeId').igTree('expand', $(this));
I do have one other problem to solve. I need to make the text and icon of the parent nodes expand the tree as well. Is there an easy way to do that?