Plugins

User login
Can't find a Plugin?

Can't find a Plugin you are looking for? Check out the jQuery Wiki page.

Are you a plugin developer? Please move your plugin over to this site.

Website Bug or Feature Request?

Found a bug on the new jQuery Plugin website? Have a feature request?

Submit it to the jQuery Plugin website issue queue to ensure it is noticed!

Expand/Contract a especific node


Project:Simple Tree +Drag'nDrop
Version:1-0.3
Component:User interface
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

How i can expand/contract a especific node form another plugin.

I´m looking somethin like this

$('#2').nodeToggle();

Comments

#1

This is a question rather than a feature request.

This is how I accomplished:
I want to expand the node with id 123
var li = $('#123', tree); //tree stores a reference to the root node
var liElem = li[0]; //search returns an array even if only one element found
//find the child of this node
var childUI = $('>ul', liElem);
if(childUl.is(':visible')){ //allready expanded
//do something here
} else {
tree.nodeToggle(liElem);
}

If you don't care if the node is expanded or not
tree.nodeToggle($('#123', tree)[0]);

#2

I keep getting a js-error.
To get the reference to the rootnode I simply use var tree = $('.root',this);
Then I use tree.nodeToggle($('#1', tree)[0]); but I get an 'Object does not support this method...' exception.

Your post helped me on the way, but after looking for half a day I can't seem to find the correct solution.

#3

I found the solution.

var simpleTreeCollection;
$(document).ready(function(){
simpleTreeCollection = $('.simpleTree').simpleTree({
autoclose: true,
drag: false,
afterClick:function(node){
//alert(node.attr('id'));
//alert($('span:first', node).text());
var loc = $('a:first', $('span:first', node)).attr('href');
window.location=loc;
//alert("text-"+$('span:first',node).text());
},
afterDblClick:function(node){
//alert("text-"+$('span:first',node).text());
},
afterMove:function(destination, source, pos){
//alert("destination-"+destination.attr('id')+" source-"+source.attr('id')+" pos-"+pos);
},
afterAjax:function()
{
//alert('Loaded');
},
animate:true,
docToFolderConvert:true
});

expand();
});

function expand()
{
simpleTreeCollection[0].nodeToggle($(expandnodeid, simpleTreeCollection[0])[0]);
}

from codebehind (since I use ASP.Net, I set the var expandnodeid). This works perfectly.

It isn't even necessary to have a reference to the rootnode. All you need to know is that simpletreecollection is a collection of multiple simpletree objects on the site. If you have one simpletree you call simpletreecollection[0]. This wasn't clear, but I figured it out.