jQWidgets Forums
jQuery UI Widgets › Forums › General Discussions › Navigation › Tree › How to expand menu in selected page?
Tagged: javascript tree, jqxtree, Tree
This topic contains 7 replies, has 2 voices, and was last updated by Peter Stoev 12 years, 9 months ago.
-
Author
-
Once the visitor clicks a link, how do I expand the menu once the linked page gets control?
I am using version jQWidgets v2.4.2 (2012-Sep-12)
Once the visitor clicks a link in the tree menu and the new page is displayed, I want the node the visitor clicked to appear expanded.
Thanks Ahead of time for your help…
Hi Richard,
You can expand/collapse an item by using the expandItem, collapseItem methods.
For example:
You can also change the jqxTree’s toggleMode property to ‘click’. By doing that, clicking an item will toggle its state(expand to collapse or collapse to expand).
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comPeter, you must be the jqWidgets guardian angle. I see how to bind the selection when the option is clicked but I do not see how to determine which option was clicked once the new page loads. I want the menu to appear expanded when the new page loads.
Hi Richard,
i.e your have the following app scenario:
Load a new page depending on a clicked item.
The new page has jqxTree with the same item.
You want the item to be expanded in the new page.Is that your scenario?
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comyes, that is correct
Hi Richard,
Then, I suggest you to give ids to your tree items. When an anchor tag is clicked, store its parent LI item’s ID in a cookie with key ‘treeSelection’. When a page is loaded, check the cookie for ‘treeSelection’. Select the item with jQuery and then use the jqxTree’s expandItem method to expand the element.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comThanks Peter but I cannot use cookies. I was hoping there was something already in the session that we could use as the key.
Hi Richard,
Another option without cookies is to use the HTML5’s localStorage.
if (window.localStorage) { window.localStorage["treeSelection"] = "id"; }
When you load the page, you can do:
if (window.localStorage) { var id = window.localStorage["treeSelection"]; if (id != undefined) { var element = $("#id")[0];} }
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.