This is a migrated thread and some comments may be shown as answers.

Help: How can I get the selected menu item in a Select event?

3 Answers 92 Views
Menu
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Arnold Smith
Top achievements
Rank 1
Arnold Smith asked on 23 Mar 2010, 07:15 PM
Hi,

I'm trying to get the selected menu item. Based on that selection I want to execute other code.

I've tried the following combination without success:

    function Select(e) {
        // "this" in this event handler will be the component.
        // the "e" is an object passed by the jQuery event trigger.
        e.stopPropagation();
        var item = $(e.item);
        var text = item.find('> item.t-link').text();
        alert(text);

        var menu = $("#Menu").data("tMenu");
        alert(menu);
        var item = $("> li", menu.selected)[$("#itemIndex").val()];
        alert(e.valueOf(item));
    }

Someone must know this...???


Thanks,

Arnold

3 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 24 Mar 2010, 09:42 AM
Hello Arnold,

As seen in the client-side events online demo, you can get the menu item text in the following way:

    function onSelect(e) {
        var item = $(e.item);
        alert(item.find('> .t-link').text());
    }


Kind regards,
Alex Gyoshev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Darrien
Top achievements
Rank 1
answered on 17 Nov 2010, 08:13 PM
What other properties are exposed besides the *.text()* one?  I have Menu Items without Text (only images).  I tried .Index() to no avail.
0
Atanas Korchev
Telerik team
answered on 18 Nov 2010, 09:02 AM
Hi Darrien,

 The .text() function is not exposed by our API - it is part of jQuery. Index is available but you should try calling it like this:

var index = $(e.item).index();

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Menu
Asked by
Arnold Smith
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Darrien
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or