TheGPWorx
TheGPWorx

Reputation: 887

How to programmatically expand fuelux treeview folders using jQuery?

I've been stuck in this problem. I am using fuelux treeview to display a list of categories and folders. What I want is to display the expanded treeview on page load. I can't seem to achieve this. I have found out that the tree folder must be clicked before the folder items are populated. So i tried to use

$('.tree-folder').trigger('click');

to trigger a click so that it may expand automatically. But this doesn't seem to work. I've tried

$('.tree-folder').click();

but it wont work too.

So how do you automatically trigger a click or just how do you automatically expand the fuelux treeview? Any ideas? Thanks in advance.

Upvotes: 0

Views: 1026

Answers (1)

Stephen Williams
Stephen Williams

Reputation: 36

You'll want to makes sure you are triggering the click event on the correct element.

https://github.com/ExactTarget/fuelux/blob/3.2.1/js/tree.js#L35-L42

For Fuel UX 3.2.1 (current as of answer) run the following in the console on http://getfuelux.com/javascript.html#tree-usage for an example.

$('#treeIllustration .tree-branch-name').trigger('click')

This triggers the openFolder method which you could call directly.

https://github.com/ExactTarget/fuelux/blob/3.2.1/js/tree.js#L198

At this point after loaded.fu.tree triggers a method could be created/called to climb the tree recursively and call openFolder

This would be a nice enhancement. Please submit an issue so that it can be prioritized. If you come up with a good solution feel free to submit a pull request.

https://github.com/ExactTarget/fuelux/issues/new

Upvotes: 2

Related Questions