Updated JS to better handle input IDs

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2022-10-20 19:21:09 -07:00
parent 4eed2baa31
commit 515b14a001

View file

@ -116,32 +116,30 @@
// These methods dynamically add/remove hidden input values in the bulk actions form
$('.snipe-table').on('check.bs.table .btSelectItem', function (row, $element) {
var buttonName = $(this).data('bulk-button-id');
var formName = $(this).data('bulk-form-id');
var tableId = $(this).data('id-table');
$(buttonName).removeAttr('disabled');
$(formName).append('<input id="' + tableId + '_checkbox_' + $element.id + '" type="hidden" name="ids[]" value="' + $element.id + '">');
$(buttonName).after('<input id="' + tableId + '_checkbox_' + $element.id + '" type="hidden" name="ids[]" value="' + $element.id + '">');
});
$('.snipe-table').on('uncheck.bs.table .btSelectItem', function (row, $element) {
var tableId = $(this).data('id-table');
$( "#" + tableId + "_checkbox_" + $element.id).remove();
});
$('.snipe-table').on('check-all.bs.table', function (event, rowsAfter) {
var buttonName = $(this).data('bulk-button-id');
$(buttonName).removeAttr('disabled');
var formName = $(this).data('bulk-form-id');
var tableId = $(this).data('id-table');
for (var i in rowsAfter) {
$(formName).append('<input id="' + tableId + '_checkbox_' + rowsAfter[i].id + '" type="hidden" name="ids[]" value="' + rowsAfter[i].id + '">');
$(buttonName).after('<input id="' + tableId + '_checkbox_' + rowsAfter[i].id + '" type="hidden" name="ids[]" value="' + rowsAfter[i].id + '">');
}
});
$('.snipe-table').on('uncheck.bs.table .btSelectItem', function (row, $element) {
var tableId = $(this).data('id-table');
$( "#" + tableId + "_checkbox_" + $element.id).remove();
});
// Handle whether or not the edit button should be disabled
$('.snipe-table').on('uncheck.bs.table', function () {