2

I have a jquery treeview as navigation for a website. I am using the options:

unique:true,
collapsed:true

but I need to have the first item expanded. I also would like to be able to toggle states in certain functions.

How can i programmatically toggle a jquery treeview item?

I have read the documentation and searched everywhere, but I can't figure it out. My javascript/jquery skills are not great, so I can't figure out how to add this feature myself.

Any help would be appreciated, thanks!

Update:

I spent so long looking at the options/source code I didn't see the "closed" class right there in the intro page. That helps a lot!

also, I found that using (pointed in the right direction by Chris Gutierrez):

$('#tree div.expandable-hitarea:first').click();

works to expand that item! Now, I just have to create my own toggle functions.

Thanks.

2
  • "I also would like to be able to toggle states in certain functions." Can you give us more details? Perhaps posting your code will make perfect sense. Commented Dec 17, 2009 at 19:39
  • Post code if you really want help. Commented Dec 17, 2009 at 19:40

2 Answers 2

2

It looks like you could just execute a click on the desired li. For the first one try something like

$("#example li.collapsable:first").click();

Or when you initially render the html, just add the "expandable" class to the first li.

Sign up to request clarification or add additional context in comments.

2 Comments

this doesn't work for me, but it did help me figure it out (I've updated my question)
The css selector I used in the answer was setup for the example in the documentation. Glad you got it working.
1

The demo at the documentation link you provided, does exactly that. The source is available. Is there a problem with the way they do it there?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.