grocy/views/viewjs/locations.js
2018-04-10 20:30:11 +02:00

44 lines
815 B
JavaScript

$(document).on('click', '.location-delete-button', function(e)
{
bootbox.confirm({
message: 'Delete location <strong>' + $(e.target).attr('data-location-name') + '</strong>?',
buttons: {
confirm: {
label: 'Yes',
className: 'btn-success'
},
cancel: {
label: 'No',
className: 'btn-danger'
}
},
callback: function(result)
{
if (result === true)
{
Grocy.FetchJson('/api/delete-object/locations/' + $(e.target).attr('data-location-id'),
function(result)
{
window.location.href = '/locations';
},
function(xhr)
{
console.error(xhr);
}
);
}
}
});
});
$(function()
{
$('#locations-table').DataTable({
'pageLength': 50,
'order': [[1, 'asc']],
'columnDefs': [
{ 'orderable': false, 'targets': 0 }
]
});
});