I use the jQuery plugin 'Footable' to build a responsive table. Normally this plugin adds an icon to every first column of every row, when the row can expand and collapse. This worked fine, untill I added an event listener that checks for a button to be clicked inside the table.
My table is put together by jQuery after data is loaded with Ajax. My jQuery looks like this:
// My table
var table = $('<table/>', {
class: 'footable table toggle-circle'
});
// My button, which gets appended to a table cell
removeLink = $('<a/>', {
'class': 'row-delete',
'href': '#'
}).text('Remove');
The code above builds me a nice table. But after I add the following event listener to my code (which works perfectly fine as well), Footable's icons no longer appear (expanding and collapsing still works):
// Listen to clicks
$('#response').footable().on('click', '.row-delete', function(e) {
/* Stuff to do here. It doesn't matter what I put here,
*/ even when it's empty icons are dismissed.
}
The table itself is as mentioned loaded by an Ajax call, which on completion initializes the Footable plugin with the following code:
$(function () {
$('.footable').footable();
});
Not only don't I understand why the icons are missing, but I cannot even understand why adding an event listener messes with the plugins output to begin with. What do I miss?