我正在使用 jQuery UI 对话框来确认删除请求。当我用户确认删除请求时,我正在尝试将 ID 传递给 AJAX 帖子。提前感谢您的任何见解。
这是HTML:
<table width="100%" cellspacing="1" cellpadding="5" border="0" class="detailTbl" id="myTable">
<tbody>
<tr class="divider" id="editRow220">
<td align="top">Lorem Ipsum is simply dummy text of the printing and typesetting industry. </td>
<td align="top">
<a class="btn_delete deleteMe form-tip" href="#" id="220" title="Delete this item"></a>
<span>Lorem Ipsum is simply dummy text of the printing and typesetting industry. </span>
</td>
</tr>
</tbody>
</table>
这是脚本:
$("#myTable tbody").on("click", "a.deleteMe", function (e) {
e.preventDefault();
var RemoveID = $(this);
alert(RemoveID.attr("id")); // ***correct ID here ***
var $myDialog = $('<div></div>')
.html('Are you sure you want to delete this item?')
.dialog({
autoOpen: false,
title: 'Confirmation',
buttons: {"Yes": function(e) {
alert(RemoveID.attr("id")); // ***RemoveID is undefined here***
// AJAX Call here //
return true;
}, "No": function() {
$(this).dialog("close");
return false;
}
}
});
return $myDialog.dialog('open');
});