row appending properly and gonig to last page

This commit is contained in:
Hash Borgir 2023-06-13 13:42:32 -06:00
parent 5a8bac8e87
commit 3ce842b52d

View File

@ -124,15 +124,15 @@ foreach (glob($tbl . "*.tbl") as $filename) {
// // Initialize DataTables on the table
// $('.table').DataTable();
// });
// });
// });
// Function to resize textarea based on content
// Function to resize textarea based on content
function resizeTextarea() {
this.style.height = 'auto';
this.style.height = (this.scrollHeight) + 'px';
}
// Select element change event handler
// Select element change event handler
$('#tableName').change(function () {
$('.table').DataTable().destroy();
$('.table tbody').html('');
@ -170,7 +170,7 @@ foreach (glob($tbl . "*.tbl") as $filename) {
// Delete link click event handler
// Delete link click event handler
$(document).on('click', '.delete-link', function (event) {
event.preventDefault();
@ -239,7 +239,7 @@ foreach (glob($tbl . "*.tbl") as $filename) {
'<td><textarea class="form-control">' + string + '</textarea></td>' +
'<td><div>' +
'<a href="#" class="update-link btn btn-primary" data-rowid="' + rowid + '">Update</a>' +
'<a href="#" class="delete-link btn btn-danger" data-rowid="' + rowid + '">Delete</a>' +
'<a style="float:right" href="#" class="delete-link btn btn-danger" data-rowid="' + rowid + '">Delete</a>' +
'</div></td>' +
'</tr>';
;
@ -250,7 +250,11 @@ foreach (glob($tbl . "*.tbl") as $filename) {
$('.table tbody').append(newRow);
$('.table').DataTable();
// Initialize DataTables on the table
var table = $('.table').DataTable();
// Go to the last page after loading the table
table.page('last').draw('page');
});
});