Trouble calling function on button click

2 posts, 0 answers
  1. Robin
    Robin avatar
    2 posts
    Member since:
    Aug 2012

    Posted 07 Aug 2012 Link to this post

    I've put together a little app using Kendo UI that stores user inputs in a Javascript array, and then prints these items out by adding text to a div. Along with the text, I need to have a delete button to remove these items from the array.

    Since I'm adding the delete buttons to the DOM after I initialize Kendo UI, I assume I need to use the.kendoMobileButton() method on each button I add. If I don't do this, my buttons aren't styled correctly, despite being given the attribute data-role="button".

    Still, when I try to use these buttons, I can't get them to call a function with data-click="deleteNumber". The function simply doesn't seem to fire. Any hints?

    Here is a quick example I threw together that illustrates my problem: http://crocdoc.ifas.ufl.edu/files/kendo_example/

  2. Robin
    Robin avatar
    2 posts
    Member since:
    Aug 2012

    Posted 08 Aug 2012 Link to this post

    @debug_mode provided the answer for me:

    You need to modify your code as following:

     $('#number_list').append('Number ' + current_index + ': ' + current_number + ' <a id="delete_' + current_index + '">Delete</a><br/>');
        $
    ('#delete_'+current_index).kendoMobileButton({click: deleteNumber});
  3. Kendo UI is VS 2017 Ready
Back to Top