jQWidgets Forums

jQuery UI Widgets Forums General Discussions Navigation Tree How to expand menu in selected page?

This topic contains 7 replies, has 2 voices, and was last updated by  Peter Stoev 12 years, 9 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • How to expand menu in selected page? #9391

    Richard
    Member

    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…

    How to expand menu in selected page? #9416

    Peter Stoev
    Keymaster

    Hi Richard,

    You can expand/collapse an item by using the expandItem, collapseItem methods.

    For example:

    settings.htm.

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    How to expand menu in selected page? #9453

    Richard
    Member

    Peter, 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.

    How to expand menu in selected page? #9454

    Peter Stoev
    Keymaster

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    How to expand menu in selected page? #9462

    Richard
    Member

    yes, that is correct

    How to expand menu in selected page? #9464

    Peter Stoev
    Keymaster

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    How to expand menu in selected page? #9468

    Richard
    Member

    Thanks Peter but I cannot use cookies. I was hoping there was something already in the session that we could use as the key.

    How to expand menu in selected page? #9471

    Peter Stoev
    Keymaster

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.