This is a migrated thread and some comments may be shown as answers.
menu, onclick(..) allowed? & hide/show items
3 Answers 192 Views
This is a migrated thread and some comments may be shown as answers.
Marco
Top achievements
Rank 1
Marco asked on 05 Apr 2012, 11:00 PM
Hi, i just dl your framework to try if covers all my needings, i have 2 question (please dont call me stupid if i didnt understood it before :) )
 
1)
i'm wondering if its right to add onclick event to a <li> markup, something like:

  <ul id="menu">
                <li>
                    File
                    <ul>
                        <li onclick="alert('ciao');">sub1</li>
                        <li onclick="doSomething(....);">sub2</li> 
.....
i cant use the onSelect handler as shown in your demos becouse user can change it, and also may exists same text in different places of the menu
seems to work..

2) i see that exists insert/add and remove items, does exists also an hide/show methods?

thx

3 Answers, 1 is accepted

Sort by
0
Kamen Bundev
Telerik team
answered on 06 Apr 2012, 10:02 AM
Hello Marco,

1. I'm not sure I understand why you don't want to use the select event, but yes - you should be able to attach event handlers with onclick="something()" too.

2. You can hide the LI elements directly with jQuery show()/hide() or with CSS only (display: none).

Regards,
Kamen Bundev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Marco
Top achievements
Rank 1
answered on 06 Apr 2012, 07:00 PM
thanks for quick reply,
1)id like to follow your official guidelines becuse if the library will be (accepted by the boss bought) my code will be compatible with your further versions. as i understood, i can check only the text property of the selected item, but id like to have some custom data;
 i did a small editing to the demo page /web/menu/events.html
...
     function onSelect(e) {
                    //kendoConsole.log("Selected: " + $(e.item).children(".k-link").text());
                    for(var propertyName in $(e.item).children(".k-link")) {
                        kendoConsole.log(propertyName);
  
                    }
..
but im unable to find a possible place where to put my own (hidden to end user) data..
how to add my additional data for the LI markup? and how to read it on the event 

2) perfectly right, forgive me for this question.. sometimes i need a rest :)

thanks again for patience


0
Kamen Bundev
Telerik team
answered on 09 Apr 2012, 01:10 PM
Hi Marco,

Currently there's no official way to store additional data on an item. We intend to offer this functionality as part of the menu hierarchical data source support we have planned. Meanwhile there are a number of ways to do this, ranging from manually iterating the items and assigning them the data to keeping the additional data in the JSON object and finding it when needed. The latter should be a better alternative since it doesn't involve iteration on init. Check the following implementation in jsFiddle:


Regards,
Kamen Bundev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Menu
Asked by
Marco
Top achievements
Rank 1
Answers by
Kamen Bundev
Telerik team
Marco
Top achievements
Rank 1
Share this question
or