Refreshing a parent window after using dlgopen()

Ok. I’ve been banging my head on this for a bit and Google hasn’t helped. I open a form using dlgopen (much like add_edit_event.php) and I want to refresh the parent tab. More specifically, I want to call a dataTable function on the parent tab. I know this is probably basic Javascript, but could someone please point me in the right direction? The specific function I want to call is " oTable.ajax.reload(); ".

dlgopen has the ability to setup a callback function. Best bet is to read the comments in openemr/library/dialog.js.
Also, there are many examples in code with a dozen different ways dlgopen handles closing, callbacks and refresh. Just do a search in code for dlgopen to see…Feel free to add to this function if you can’t do something.

An example:
Setup a function in the same scope as dlgopen such as
function refreshme() {
top.restoreSession();
oTable.ajax.reload();
}
and the dlgopen: this shows various ways to setup functions to buttons and onClosed e.t.c. Just remember that only the callBack option allows arguments. All others must not included them or ().

function editScripts(url) {
var AddScript = function () {
var iam = top.tab_mode ? top.frames.editScripts : window[0];
iam.location.href = “<?php echo $GLOBALS[‘webroot’]?>/controller.php?prescription&edit&id=&pid=<?php echo attr($pid);?>”
};
var ListScripts = function () {
var iam = top.tab_mode ? top.frames.editScripts : window[0];
iam.location.href = “<?php echo $GLOBALS[‘webroot’]?>/controller.php?prescription&list&id=<?php echo attr($pid); ?>”
};

let title = ‘<?php echo xla(‘Prescriptions’); ?>’;
let w = 810;
<?php if ($GLOBALS[‘weno_rx_enable’]) {
echo ‘w = 910;’; }?>

dlgopen(url, ‘editScripts’, w, 300, ‘’, ‘’, {
buttons: [
{text: ‘<?php echo xla(‘Add’); ?>’, close: false, style: ‘primary btn-sm’, click: AddScript},
{text: ‘<?php echo xla(‘List’); ?>’, close: false, style: ‘primary btn-sm’, click: ListScripts},
{text: ‘<?php echo xla(‘Done’); ?>’, close: true, style: ‘default btn-sm’}
],
onClosed: ‘refreshme’,
allowResize: true,
allowDrag: true,
dialogId: ‘editscripts’,
type: ‘iframe’
});
}