jQuery Bootstrap confirmation on dynamically created button -


i have code below works on buttons inserted via regular html. when add button dynamically jquery, button doesn't work. tried using previous stackoverflow response, can't work. appreciated.

the answer found:

$(staticancestors).on(eventname, dynamicchild, function() {}); 

my code

$('.mini-admin').confirmation({     placement: 'left',   onconfirm: function(event, element) {        var c = $( element ).data('row');        $.ajax({             type: "post",             url: "_scripts/deleteuser.php",             data: {c: c},             context: document.body,             success: function(){                 $( '#row_' + c ).fadeout();                 console.log('1');             }       });   },   oncancel: function() { } }); 

this code work on second click, can't figure out how make work on first click!

$('table.users-form').on('click', '.mini-admin', function() {     $('.mini-admin').confirmation({         placement: 'left',       onconfirm: function(event, element) {            var c = $( element ).data('row');            $.ajax({                 type: "post",                 url: "_scripts/deleteuser.php",                 data: {c: c},                 context: document.body,                 success: function(){                     $( '#row_' + c ).fadeout();                     console.log('2');                 }           });       },       oncancel: function() { }     });    }); 

wrapping original code in block made work. (don't ask me why)

jquery(document).ajaxcomplete(function( event,request, settings ) {  }); 

Comments