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

Trouble calling function on button click

1 Answer 85 Views
Button (Mobile)
This is a migrated thread and some comments may be shown as answers.
Robin
Top achievements
Rank 1
Robin asked on 07 Aug 2012, 08:06 PM

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/

1 Answer, 1 is accepted

Sort by
0
Robin
Top achievements
Rank 1
answered on 08 Aug 2012, 02:07 PM
@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});
Tags
Button (Mobile)
Asked by
Robin
Top achievements
Rank 1
Answers by
Robin
Top achievements
Rank 1
Share this question
or