jQWidgets Forums

jQuery UI Widgets Forums Navigation Menu, Context Menu Default Select Menu Item.

This topic contains 3 replies, has 2 voices, and was last updated by  Dimitar 11 years, 1 month ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Default Select Menu Item. #54444

    hemant.kalal
    Participant

    Hi,

    How can I make a menu Item to be selected by default , ie. when the menu loads, In my case I want to make the second Menu Item selected.

    Thanks
    Hemant.

    Default Select Menu Item. #54488

    Dimitar
    Participant

    Hello Hemant,

    You can try this:

    $('#jqxMenu').on('initialized', function () {
        $("#secondItem").click();
    });

    followed by the menu initialization code, where secondItem is the id of the second menu item.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Default Select Menu Item. #54496

    hemant.kalal
    Participant

    Hi Dimitar,

    How will I get Id of the second menu Item during initialization , I can get it during click.

    Thanks
    Hemant.

    Default Select Menu Item. #54542

    Dimitar
    Participant

    Hi Hemant,

    If your menu is loaded from an HTML structure, you can set the id of the li element corresponding to your default menu item. E.g., the “Products” item in this fiddle: http://jsfiddle.net/jqwidgets/vRjng/.

    If you have initialized from a different source (such as XML or JSON), items would also have ids and you can use them in your code. You can also do the following:

    $('#jqxMenu').on('initialized', function () {
        var secondItem = $('#jqxMenu').children().children()[1];
        setTimeout(function () {
            $(secondItem).click();
        }, 100);
    });

    Note that a small delay is sometimes needed, thus the timeout.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

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

You must be logged in to reply to this topic.