diff --git a/resources/components/modal/delete.blade.php b/resources/components/modal/delete.blade.php index 1278140..3d9ed6c 100644 --- a/resources/components/modal/delete.blade.php +++ b/resources/components/modal/delete.blade.php @@ -10,7 +10,7 @@
@@ -23,13 +23,37 @@ $(document).ready(function() { $('.{{$trigger}}').click(function(e) { confirm_delete.show(); - console.log($('#confirm_delete') - .find('.btn-ok')); + $('#confirm_delete') .find('.btn-ok') - .attr('href',e.currentTarget.href); + .attr('href',$(this).attr('href')) + .attr('data-id',$(this).data('id')); + return false; }); + + $('.btn-ok').click(function(item) { + var that = $(this); + + // Delete + $.ajax({ + url: that.attr('href'), + method: 'POST', + dataType: 'json', + + }).done(function(data) { + if (that.data('hide') == 'row') + $('a[data-id="'+that.data('id')+'"].{{$trigger}}').closest('tr').hide(); + + }).fail(function() { + alert('Hmm, that didnt work?'); + }); + + // Clear the data cache + that.removeData(); + confirm_delete.hide(); + return false; + }) }); @append \ No newline at end of file