jquery - Kendo contextMenu select function for specific items -


i'm trying create contextmenu usig kendocontextmenu widget. works using following code.

$("#contextmenu").kendocontextmenu({ target: "#tree", filter: ".k-item", select: function(e) {     alert("selected"); }, datasource: [     { text: "item1"},     {         text: "submenu1",         items: [             { text: "item1" }         ]     },     {         text: "submenu2",         items: [             { text: "item1" }         ]     } ] }); 

but want specify function each item execute when item clicked. don't want determine execute based on text contents.

i've tried add click item in datasource doesn't seem work.

kendo contextmenu doesn't have feature, have 2 options:

first, configure context menu using html onclick events:

<ul id="menu">     <li>         option 1         <ul>             <li onclick="alert('test');">sub option 1</li>             <li>sub option 2</li>         </ul>     </li>     <li>option 2</li> </ul> <script>     $(document).ready(function() {                 $("#menu").kendocontextmenu({                 orientation: orientation,             });         };     }); </script> 

second, if can ensure name uniqueness can add click properties in datasource configuration , on context menu select event can search in datasource appropriate item , execute attached function manually.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -