jQuery treeview plugin collapse/expand to the newly added node
I am using jQuery treeview plugin and the following is the example code for adding branches to the tree.
var newLi = jQuery(strListString).appendTo(objParentULjQuery);
jQuery(objParentULjQuery).treeview({add: newLi});
After adding the new node it should be selected. How it is possible?
After that I need to expand/collapse to the newly added node. How can I do that?
// binding onclick event
$(objParentLI).find("div.hitarea").live("click",function() {
//under li class to be chaged to expandable/collapsable according to the node event
//under li div class to be changed to "hitarea expandable-hitarea" or collapsable collapsable-hitarea
//under li span the style should be开发者_JAVA百科 display:none;
if($(objParentLI).hasClass('collapsable'))
{
$(objParentLI).removeClass('collapsable').addClass('expandable');
$(objNew).removeClass('collapsable-hitarea').addClass('hitarea expandable-hitarea');
$(newLi).css("display", "none");
}
else if($(objParentLI).hasClass('expandable'))
{
$(objParentLI).removeClass('expandable').addClass('collapsable');
$(objNew).removeClass('expandable-hitarea').addClass('hitarea collapsable-hitarea');
$(newLi).css("display", "block");
}
});
Please support me in this issue and let me know any questions.
Probably the easiest thing to do is:
newLi.click();
After the line that adds it to the tree view. Not sure what you mean by selected.
精彩评论