Jquery confirm() in an attached event handler -


i have delete buttons in list populated ajax call. these buttons suppose trigger confirm dialog, cannot confirm dialog display when called in click event handler. need separate handler? hope can direct me towards solution.

$('#list').on('click', '.btnremovenote', function () {                                    $(this).confirm({                     msg: 'do want remove this?'                 });                                   }); 

this how list generated

function funcloadlist(racodeid) {     if (racodeid == null || racodeid == '') { console.log('bypassing list load, racodeid null'); return; }     console.log("load list function initiated " + 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 connection error: ' + xhr.status + '\n please try again later.');             console.log('there 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 no notes member. use "add member note/document" area add 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 scheduled ' + 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 sent on ' + followupinfo + ' ' + 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 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 want remove this?  "});<\/script>'                     );                  $('#list').append(tr);              });         }     });      $('#liststatus').text('');     console.log("load list function complete...");     return true; } 

just use javascript confirm.

$('#list').on('click', '.btnremovenote',   function () {                        confirm('do want remove this?');   }                     ); 

i think there no $(this).confirm() in jquery, .dialog has more parameters. read here. use if want.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -