toggle ok

This commit is contained in:
2019-08-27 08:42:32 +02:00
parent bd0b562dcd
commit 9b9a94a83b
3 changed files with 136 additions and 72 deletions

View File

@@ -85,7 +85,7 @@
</div>`;
$('#example2').DataTable({
var table = $('#example2').DataTable({
'ajax': '/json/status',
"columns" : [
{ "data" : 0 },
@@ -103,10 +103,23 @@
// fa-toggle-off
$('#example2 tbody').on( 'click', '[script="toggle"]', function () {
alert( 'ciao' );
$('#example2 tbody').on( 'click', '[script="toggle"]', function (e) {
e.preventDefault();
var id = $( this ).closest('tr').find('td:first').text();
$.ajax({
url: '/json/outlet/'+id+'/toggle',
type: 'post'
})
.done(function(result) {
console.log(result);
table.ajax.reload();
})
.fail(function(jqXHR, textStatus, errorThrown) {
// needs to implement if it fails
console.log(textStatus);
});
});
});
} );