simonexmachina / jquery-bonsai

Super lightweight jQuery tree plugin
http://simonwade.me/jquery-bonsai
MIT License
148 stars 42 forks source link

Identifying Whole tree state #31

Closed nikhilbhatia22 closed 8 years ago

nikhilbhatia22 commented 8 years ago

Great Project!

I wanted to know, how can I identify state of whole tree... Basically, i am wishing to toggle expand/collapse state of whole tree with single hyperlink...

simonexmachina commented 8 years ago

Thanks! I think you can call .bonsai('expandAll'). There's also an addExpandAll option. These should both be in the docs, feel like doing a PR?

nikhilbhatia22 commented 8 years ago

Yes, I am using #expandAll & #collapseAll currently, Also, I checked addExpandAll option, but these all options creates two different separate links for expanding and collapsing... And as i said earlier, I want to toggle it with single hyperlink only... So, for that, I want to identify tree's current state i.e. if tree's current state is expanded then that single hyperlink onClick would change its state to collapsed and vice versa...

simonexmachina commented 8 years ago

Ok, you can do that with a simple query: $('#tree').find('.expanded').length > 0

nikhilbhatia22 commented 8 years ago

Thank you so much man.! Great project.!

simonexmachina commented 8 years ago

You're welcome :)