附加事件处理程序中的Jquery confirm()

附加事件处理程序中的Jquery confirm(),jquery,jquery-confirm,Jquery,Jquery Confirm,我在由AJAX调用填充的列表中有删除按钮。假设这些按钮触发一个确认对话框,但在这个单击事件处理程序中调用时,我无法显示确认对话框。我需要一个单独的处理程序吗?我希望有人能指导我找到解决办法 $('#list').on('click', '.btnRemoveNote', function () { $(this).confirm({ msg: 'Do you really want to

我在由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>&nbsp;</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>&nbsp;</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;
}
函数funcLoadList(racodeID){
if(racodeID==null | | racodeID==''){console.log('bypassing list load,racodeID为null');return;}
console.log(“为“+racodeID”启动加载列表功能);
$('.table row').remove();
var url='';
var downloadUrl='';
$.ajax({
url:url,
数据:{RacodeID:RacodeID},
beforeSend:函数(){
$('#listStatus').text('更新列表…');
},
完成:函数(){
//$('#fileStatus').text('请求完成…');
},
数据类型:“json”,
url:url,
async:false,
键入:“POST”,
错误:函数(xhr、状态、错误抛出){
$(“#listStatus”).text('很抱歉,出现连接错误:'+xhr.status+'\n请稍后再试');
log('出现错误:'+xhr.status+'-'+xhr.responseText);
返回错误抛出;
}
})
.完成(功能(数据){
$(“#列表”).show();
$('.list no note').remove();
如果(数据=“”){
$(“#列表”).hide();
$(“#listContainer”).append('此成员没有注释。请使用“添加成员注释/文档”区域添加第一个注释');
$('.exportNotesLink').hide();
}
否则{
$。每个(数据、功能(i、项){
var followRequired=false;
var followUpBtn='';
var followUpInfo='';
var面积=“”;
if(item.followUpEmailSentOn!=null)
followUpInfo=新日期(parseInt(item.followUpEmailSentOn.substr(6));
var fulfilledBtn=‘fulfilledBtn’;
item.dateCreated=新日期(parseInt(item.dateCreated.substr(6));
如果(item.followUpDate!=null){
followRequired=true;
item.followUpDate=新日期(parseInt(item.followUpDate.substr(6));
}else{item.followUpDate=“N/A”;}
如果(项目.已完成){
fulfilledBtn=‘Fulfilled’;
}否则{
已完成的BTN=‘未完成的’;
}
如果(!item.followUpEmailSent&&item.followUpDate!='N/A'&&&!item.isfollowDup){
followUpBtn='“class=”followUpBtn“title=”计划为'+item.followUpDate+'“/>'执行后续操作;
}
if(item.followUpEmailSent&&item.followUpDate!='N/A'&&item.followUpEmailSentOn!=null){
followUpInfo='“height=“20px”style=“vertical align:middle”/>在“+followUpInfo+”向“+item.followUpEmail+”发送了一封后续电子邮件;
}
if(item.comment!=null&&item.comment!=''){
commentArea='Comment:'+item.Comment+'

; } //日志(“内部循环…”); var表; var短文件名; var-iconFile=''; var followupDate=''; 如果(item.fileName!=''&&item.fileName!=null&&item.fileName.length>25) shortFileName=jQuery.trim(item.fileName).substring(0,25).trim(this)+“…”; 其他的 shortFileName=item.fileName; if(shortFileName!=''&&shortFileName!=null){ iconFile='“height=“20px”title=“下载此文档”class=“masterTooltip”style=“垂直对齐:中间”/>; } if(item.followUpDate==null) followupDate='不适用'; 其他的 followupDate=item.followupDate; var tr=( '' + ''+实现了BTN+''功能+ ' ' + ''+项目描述+''+ ''+item.requestTakenBy+''中的“+item.requestTakenBy”+ '" />' + ' ' + '' + '' + ''+followUpBtn+''后+ ''+commentArea+iconFile+''+shortFileName+''+ '' + '' + '跟进日期:'+item.followUpDate+''+ '' + ''+后续信息+''+ “$”(“.btnRemoveNote”)。确认({msg:“是否确实要删除此?”});' ); $('#list')。追加(tr); }); } }); $('#listStatus')。文本(''; 日志(“加载列表功能完成…”); 返回true; }
只需使用JavaScript确认

$('#list').on('click', '.btnRemoveNote',
  function () {                   
    confirm('Do you really want to remove this?');
  }                    
);

我认为JQuery中没有$(this).confirm(),只有.dialog,它有更多的参数。阅读如果需要,您可以使用它。

只需使用JavaScript确认

$('#list').on('click', '.btnRemoveNote',
  function () {                   
    confirm('Do you really want to remove this?');
  }                    
);

我认为JQuery中没有$(this).confirm(),只有.dialog,它有更多的参数。阅读如果您愿意,可以使用它。

除非您使用的是插件,否则没有jQuery确认方法。如果您正在使用插件,插件文档将向您展示如何显示它。检查控制台是否有错误除了第一条评论中的内容外,请公布您创建按钮的方式,这可能是ajax调用检查后的事件绑定问题,除非您使用插件,否则没有jQuery确认方法。如果您正在使用插件,插件文档将向您展示如何显示它。检查控制台是否有错误除了第一条评论中的内容外,请公布创建按钮的方式,这可能是ajax调用检查后的事件绑定问题