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

Initialize context menu before its target

3 Answers 128 Views
Menu
This is a migrated thread and some comments may be shown as answers.
BigzampanoXXl
Top achievements
Rank 1
BigzampanoXXl asked on 19 Sep 2014, 01:09 PM
Hello,

is it possible to initialize a context menu before its target is existing in the DOM? I want to have the context menu on a grid which is initialized sometime later. Here is a simple example which will show you what I tried to do:
$("#context-menu").kendoContextMenu({
        target: "#target"
  });
   
$('body').append('<div id="target">Target</div>');

I know that it would work if I append the div before I initialize the context menu but I would like to define it for every element with the same ID no matter when it will appear in the DOM. Is there any possibility to do this?

Thank you

3 Answers, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 19 Sep 2014, 03:43 PM
Hi Dietmar,

The desired behavior is not supported, because the ContextMenu needs to attach a handler to the target element during initialization.

Regards,
Dimo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
BigzampanoXXl
Top achievements
Rank 1
answered on 26 Sep 2014, 12:34 PM
Hi Dimo,

thank you for your reply.

You should check the documentation page of the ContextMenu. A lot of the examples there don't work (e.g.: the "enable" example):
http://docs.telerik.com/kendo-ui/api/javascript/ui/contextmenu#methods-enable

Best regards
0
Dimo
Telerik team
answered on 29 Sep 2014, 02:39 PM
Hi Dietmar,

Yes, we are in the process of fixing such snippets across all API pages.

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