Dynamically added buttons not recognized

Thread is closed for posting
2 posts, 0 answers
  1. Nathaniel
    Nathaniel avatar
    7 posts
    Member since:
    Feb 2015

    Posted 18 Jun 2015 Link to this post

    When one of my views is loaded, I make an AJAX call with data-init and then dynamically create div elements with some <span>text</span> inside. The divs have data-role="button" and data-click="myFunction". When I test the template on another page (not created dynamically) everything works great. But when dynamically added, the buttons are not recognized as buttons and myFunction doesn't fire.

    Note, I am not using kendo templating to add the divs, I am using .append('with my html in here').

    How can I dynamically add button and still have them recognized?


  2. Tsvetina
    Tsvetina avatar
    2481 posts

    Posted 23 Jun 2015 Link to this post

    Hello Nathaniel,

    This is expected behavior, since the Kendo UI initalization logic has already passed at the time you insert your HTML into the page.

    You can use the kendo.init method to trigger Kendo UI to instantiate all dynamically loaded widgets. You need to pass the id of the element that contains the buttons, as well as kendo.mobile.ui namespace as a second parameter:

    kendo.init($("#container-element-id"), kendo.mobile.ui);


    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

Back to Top