I have the following html code which represents a part of a table
<tr>
<td>
<span class='tip'><a href='#' class='Delete' data-name='product1' title='Delete'><img src='images/icon/icon_delete.png'></a></span>"
</td>
</tr>
<tr>
<td>
<span class='tip'><a href='#' class='Delete' data-name='product2' title='Delete'><img src='images/icon/icon_delete.png'></a></span>"
</td>
</tr>
and some JS
$(document).on('click', '.Delete', function () {
var name = $(this).attr("data-name");
$.confirm({
'title': 'DELETE ROW',
'message': "<strong>DO YOU WANT TO DELETE </strong><br /><font color=red>' " + name + " ' </font> ",
'buttons': {
'Yes': {
'class': 'special',
'action': function () {
// this is the problem
// i am trying to get the row
var row = $(this).closest("tr").get(0);
oTable.fnDeleteRow(row);
}
},
'No': { 'class': '' }
}
});
});
I am trying to get the row id so i will be able to delete it.
how can i pass the caller to the click event
EDIT: i am trying to delete a row, maybe there are other ways
Your problem is that inside the $.confirm plugin’s
actioncallback function, the value ofthisis likely something else (i.e. not the DOM node). save a reference to$(this)before calling the plugin, and use that reference inside theactioncallback. something like:This is a bit of guess, since I’m not farmilar with your confirm plugin, but it’s a common JS pitfall.