This topic is locked

Reload parent page when popup form closes

11/19/2023 11:15:43 AM
PHPRunner General questions
P
PK author

Hello,
I have seen many topics regarding my problem but none of them is quite specific to what I need:
From a list page I use a button to open another list page in popup:
Client After

Runner.displayPopup( {
url: "eval_select_list.php",
width: 900,
height: 600,
header: 'Select Evaluators',
footer: '<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>',

afterCreate: function(win) {
window.win = win;
}
});

Then I have a button on the popup page to

  1. do some action
  2. close popup
  3. reload first list page

Step 1 and 2 are ok but step 3 doesnt work. Page needs to be realoaded manually.

I am using this code in Client After of the button on the popoup page

window.parent.win.close();
window.parent.reload();

I also tried:

window.location.href = "first_list.php?parameters";

Also

location.href="first_list.php";

But it doesnt work. Any help please..

fhumanes 11/29/2023

Hello,

If you have the code, I am not able to see where the error is.

In some examples I have used another method to recharge "programmingly" the "Master" page.

URL: https://fhumanes.com/blog/guias-desarrollo/guia-66-calendario-de-actividades-de-un-club/

In event: "After Record Added":

// Close Windows Popup
$html = <<<EOT
<html>
<head>
<meta charset='utf-8' />
</head>
<body>
<div>
New updated request

</div>
<script>
window.parent.location.reload();
</script>
</body>
</html>
EOT;
echo $html;
exit();

What he does is create an answer page where to tell you what the page to recharge is.

Greetings,
fernando

Dalkeith 11/29/2023

This works for me

Reload page automation

P
PK author 11/30/2023

Thanks for the resposes.
The first solution may not work for me becuase the popup window does not add a record. It has a button that uses server server side code to add some records directly to a table and then closes. And there is no "After Record Added" because the popup is a list with no inline add.

The second solution seems straight forward enough and I had tried it before. I took great care again to follow the steps proposed in the link but it doesnt work. I am getting frustrated at myself becuase it seems simple to do:
On this list page I set window variable using the js onload event:

img alt

Then I use a button to open the second list page in popup:

img alt

The I use a button on the popup window to do some action, close the popup and then try to reload the first list:

img alt

I really am lost as to why its not working.

fhumanes 11/30/2023

Hello,

When I facilitated the code for the event "After Record Added", it was because I understood that you were updating information, but I have already understood your problem.

There is a concept error, with a 3 -states button you can create the Popup window, but you cannot close it, because if you close it you would not let the ususary interact with the created window (the 3 states/codes are executed without stop)

To close the window you need that in the popup window you have another 3 states button where you can include the JavaScript code:

window.parent.popup.close();
parent.location.reload();

This works to me, but I am opening the popup using:.

// create a form to enter element
var url = "kanban_add.php?boardId="+boardId;
var header = 'Add Task ';
window.popup = Runner.displayPopup({url : url,
width: 900,
height: 550,
header: header
});

Regards,
fernando

P
PK author 12/5/2023

Hello fernando. Thank you.
I think was not very clear with my question. My problem is not with closing the popup. That one works fine. The problem is reloading the first page when the popup loses. I have other situations where the popup is the "Add" or "Edit" page of the list and it is straight-forward to reload the list page when the popup closes.
In the particular case the popup is only a list belonging to a different table. The popup takes some action (directly in the db) which affects the data in the first list so once the popup closes, I needed to reload the list. This is where I am stuck.
Regards,
Percy