Initialize context menu before its target

4 posts, 1 answers
  1. BigzampanoXXl
    BigzampanoXXl avatar
    60 posts
    Member since:
    Jan 2007

    Posted 19 Sep 2014 Link to this post

    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
  2. Answer
    Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 19 Sep 2014 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. BigzampanoXXl
    BigzampanoXXl avatar
    60 posts
    Member since:
    Jan 2007

    Posted 26 Sep 2014 in reply to Dimo Link to this post

    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
  5. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 29 Sep 2014 Link to this post

    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!
     
Back to Top
Kendo UI is VS 2017 Ready