This topic is locked

Runner.displayPopup() vs. "open in popup" checkbox for ADD page (v10)

10/9/2024 12:09:55 PM
PHPRunner General questions
S
StephenB author

I have an ADD page defined on a table, and if I check the box "open in popup", the standard 'Add new' button opens the page like this:

img alt

But if I try to open the same page using Runner.displayPopup(), as follows:

Runner.displayPopup({
url: "email_add.php",
width: 800,
height: 762
});

then the page opens like this, including the left bar menu and site headers & footers:

img alt

Is there a way of getting Runner.displayPopup() to just show the page form content, like the first image?

S
StephenB author 10/9/2024

Also, another difference is that after clicking 'Save' in the native popup add, the popup is automatically closed, but when using Runner.displayPopup(), the popup stays open but shows the email_list page.

There must be a way of reproducing the native behaviour in button code using Runner.displayPopup() or some other method?

G
Grdimitris 10/9/2024

Assuming that to display with Runner.displayPopum you are using a button in list page.
Create in Designer a second add page and remove left menu and any other you do not want. the new add page is named 'add1', but you can change the name.
the display popup now is
Runner.displayPopup({
url: "email_add.php",
width: 800,
height: 762,,
afterCreate: function(popup) {
window.popup = popup;

},
beforeClose: function(popup) {
location.reload();
}
});
return false; // For stop the execution of server side and Client after.

in email add page go to Javascript on load event and write this
this.on('beforeSave', function(formObj, fieldControlsArr, pageObj){
window.parent.popup.close();
return true;
});
Do not forget the return true; otherwise record will not saved.

In after record added for email table add
$_SESSION['saved']='yes';

In Before display event add
if ($_SESSION['saved']=='yes')
{
$pageObject->setProxyValue("saved", "yes");
$_SESSION['saved']=='no';}

and finaly in Javascript oLoad event add
if(proxy['saved']=='yes'){
window.parent.popup.close();
}

S
StephenB author 10/10/2024

Thanks. I'd already gone down the route of adding a second page with the menu removed, etc., but the tip re closing the popup is very helpful - I'll give that a try!

However, I now have 2 Add pages to maintain for the same purpose, whereas it would be a lot nicer to be able to access the native 'open in a popup' functionality on the default Add page. Do we know what the native 'Add new' button is doing in order to achieve this?