forked from OpenPDU/openpdu
toggle ok
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
} );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user