我在由 AJAX 调用填充的列表中有删除按钮。假设这些按钮会触发确认对话框,但在此单击事件处理程序中调用时,我无法显示确认对话框。我需要单独的处理程序吗?我希望有人可以指导我找到解决方案。
$('#list').on('click', '.btnRemoveNote', function () {
$(this).confirm({
msg: 'Do you really want to remove this?'
});
});
这就是列表的生成方式
function funcLoadList(racodeID) {
if (racodeID == null || racodeID == '') { console.log('bypassing list load, racodeid was null'); return; }
console.log("Load List function initiated for " + racodeID);
$('.table-row').remove();
var url = '<%= Url.Action("MemberGetNoteList", "AccessCodes") %>';
var downloadUrl = '<%= Url.Action("MemberDownloadNoteDocument", "AccessCodes") %>';
$.ajax({
url: url,
data: { RacodeID: racodeID },
beforeSend: function () {
$('#listStatus').text('Updating List...');
},
complete: function () {
// $('#fileStatus').text('Request complete...');
},
dataType: 'json',
url: url,
async: false,
type: 'POST',
error: function (xhr, status, errorThrown) {
$('#listStatus').text('Sorry, there was a connection error: ' + xhr.status + '\n Please try again later.');
console.log('There was a error: ' + xhr.status + ' - ' + xhr.responseText);
return errorThrown;
}
})
.done(function (data) {
$('#list').show();
$('.list-no-note').remove();
if (data == '') {
$('#list').hide();
$('#listContainer').append('<div class="list-no-note">There are no notes for this member. Use the "Add Member Note/Document" area to add your first note.</div>');
$('.exportNotesLink').hide();
}
else {
$.each(data, function (i, item) {
var followRequired = false;
var followUpBtn = '';
var followUpInfo = '';
var commentArea = '';
if (item.followUpEmailSentOn != null)
followUpInfo = new Date(parseInt(item.followUpEmailSentOn.substr(6)));
var fulfilledBtn = '<span class="fulfill unfulfilled" >Fulfilled</span>';
item.dateCreated = new Date(parseInt(item.dateCreated.substr(6)));
if (item.followUpDate != null) {
followRequired = true;
item.followUpDate = new Date(parseInt(item.followUpDate.substr(6)));
} else { item.followUpDate = "N/A"; }
if (item.isFulfilled) {
fulfilledBtn = '<span class="fulfill fulfilled" >Fulfilled</span>';
} else {
fulfilledBtn = '<span class="fulfill unfulfilled" >UnFulfilled</span>';
}
if (!item.followUpEmailSent && item.followUpDate != 'N/A' && !item.isFollowedUp) {
followUpBtn = '<img src="<%= ResolveUrl("~/Content/Images/Icons/followup_icon.png") %>" class="followUpBtn" title="A followup is scheduled for ' + item.followUpDate + '" />';
}
if (item.followUpEmailSent && item.followUpDate != 'N/A' && item.followUpEmailSentOn != null) {
followUpInfo = '<img src="<%= ResolveUrl("~/Content/Images/Icons/checkmark.png") %>" height="20px" style="vertical-align:middle"/><span style="color:green">A Follow-up email was sent on ' + followUpInfo + ' to ' + item.followUpEmail + '</span>';
}
if (item.comment != null && item.comment != '') {
commentArea = '<b>Comment:</b><span class="noteComment" > ' + item.comment + '</span><br /><br />';
}
//console.log("inside loop...");
var table;
var shortFileName;
var iconFile = '';
var followupDate = '';
if (item.fileName != '' && item.fileName != null && item.fileName.length > 25)
shortFileName = jQuery.trim(item.fileName).substring(0, 25).trim(this) + "...";
else
shortFileName = item.fileName;
if (shortFileName != '' && shortFileName != null) {
iconFile = '<img src="<%= ResolveUrl("~/Content/Images/Icons/text_icon.png") %>" height="20px" title="Download this document" class="masterTooltip" style="vertical-align:middle"/>';
}
if (item.followUpDate == null)
followupDate = 'N/A';
else
followupDate = item.followUpDate;
var tr = (
'<tr style="border-top:1px solid gray" class="table-row">' +
'<td class = "' + item.ID + '"> ' + fulfilledBtn + '</td>' +
'<td> </td>' +
'<td><span class="NoteDesc">' + item.description + '</span></td>' +
'<td>' + item.requestTakenBy + '</td>' +
'<td align="right"><a class="btnRemoveNote"><img class="' + item.ID + '" src="<%= ResolveUrl("~/Content/Images/Icons/delete-icon.png") %>" /></a></td>' +
'<td> </td>' +
'</tr>' +
'<tr class="table-row">' +
'<td colspan = "2" >' + followUpBtn + '</td>' +
'<td colspan="3" >' + commentArea + iconFile + '<a class="downloadUserFile"><span class="' + item.ID + '">' + shortFileName + '</span></a></td>' +
'<td></td>' +
'</tr><tr class="table-row">' +
'<td colspan="6" style="padding-left:30px;padding-right:20px;padding-bottom:10px;"><i><b>Follow-up Date:</b> ' + item.followUpDate + '</i></td></tr>' +
'</tr><tr class="table-row">' +
'<td colspan="6" style="padding-left:30px;padding-right:20px;padding-bottom:10px;">' + followUpInfo + '</td></tr>' +
'<script>$(".btnRemoveNote").confirm({msg: "Do you really want to remove this? "});<\/script>'
);
$('#list').append(tr);
});
}
});
$('#listStatus').text('');
console.log("Load List function complete...");
return true;
}