Refresh editor form after performing soft delete in server side php
Refresh editor form after performing soft delete in server side php

https://jyorkejudge.org
I click on Edit Address which opens up form addressEditor. AddressEditor contains a bunch of stuff including two datafields which are of type datatable. One is Resident, the other (bottom most one) is Comments.
From the comments dt, I can edit or delete. The delete is tied to the commentsEditor form & it prompts for a confirmation and issues a submit:
{ extend: 'remove', editor: commentsEditor,
formButtons: [
{
label: 'Delete',
className: 'btn-danger',
fn: function (e) {
// Custom logic here
this.submit(); // Submit the form
}
Comments editor ajex url 'php/Addresses_Comments_Nested_DT.php'. Within this PHP, I am seeing if the action "remove" is within $_POST. If I find it, I am doing an update query that is setting multiple fields including an inactive flag. Afterwards, the continues and it's setup to not include any rows from ActLog that has the active flag set.
Everything works except after the soft delete happens, then comment does not disappear from the open addressEditor form. If I close, refresh, it's gone.
I thought perhaps I need to capture the submitSuccess for commentsEditor and try to reload the data:
commentsEditor.on('submitSuccess', function () {
console.log ('commentsEditor submit success');
addresseditor.datatable.api().ajax.reload();
addresseditor.field('Comments').dt().ajax.reload();
});
This code fires but it doesn't refresh the list of comments under addresseditor
Answers
I think I got it:
commentsEditor.on('submitSuccess', function () {
console.log ('commentsEditor submit success');
addresseditor.field('Comments').dt().ajax.reload();
});