This topic is locked

close bootstrap popup after pressing save button

9/28/2016 10:46:39 AM
PHPRunner General questions
A
andreas.knab author

Hi Togehter,

I want to Close a bootstrap popup after pressing "save".
I tried many ways to position "win.close()" without success.(JS on load, after edit/add)
I used this from the blog
Show 'View customer' button on each row of Orders List page

Insert a button into Orders List page grid.
Server code

$record = $button->getCurrentRecord();

$result["CustomerID"] = $record["CustomerID"];

ClientAfter code

var win = Runner.displayPopup( {

url: "customers_view.php?editid1="+result["CustomerID"],

width: 700,

height: 500,

header: 'View customer'

});


I only was able to open it and Close it at the same time without pessing anything.

thx in advance for your help!!

Andreas

admin 10/3/2016

Here is an example of opening Add page in popup from button's code, closing it on Save button click and refreshing the List page after that so new record can be seen:

  1. Button's ClientBefore code

window.popup = Runner.displayPopup( {

url: "Categories_add.php",

width: 700,

height: 700,

header: 'Add Category'

});


2. AfterAdd event

$pageObject->setProxyValue('saved', true);

echo "<!doctype html>";


3. Javascript OnLoad event of Add page

if ( (proxy['saved'] ) && window.parent && window.parent.popup ) {

// close popup

window.parent.close();

// refresh list page

window.parent.location.reload();

}
A
andreas.knab author 10/3/2016



Here is an example of opening Add page in popup from button's code, closing it on Save button click and refreshing the List page after that so new record can be seen:

  1. Button's ClientBefore code

window.popup = Runner.displayPopup( {

url: "Categories_add.php",

width: 700,

height: 700,

header: 'Add Category'

});


2. AfterAdd event

$pageObject->setProxyValue('saved', true);

echo "<!doctype html>";


3. Javascript OnLoad event of Add page

if ( (proxy['saved'] ) && window.parent && window.parent.popup ) {

// close popup

window.parent.close();

// refresh list page

window.parent.location.reload();

}




Hi Sergey,

thx for your example..it works fine. Unfortunately it isn't working (popup is still not closing) when using my question above.

Is there maybe something I need to Change when transporting the ID in the URL like : "customers_view.php?editid1="+result["CustomerID"],

Or is it because in code was added to the Client after tab...or other reasons...????

Thx

Andreas

admin 10/3/2016

Your question doesn't really make sense in the way it is asked. On View page there is no 'Save' button so it is not clear what you trying to achieve.

A
andreas.knab author 10/4/2016



Hi Sergey,

thx for your example..it works fine. Unfortunately it isn't working (popup is still not closing) when using my question above.

Is there maybe something I need to Change when transporting the ID in the URL like : "customers_view.php?editid1="+result["CustomerID"],

Or is it because in code was added to the Client after tab...or other reasons...????

Thx

Andreas



Hi Sergey,

Sorry it was too late in the night. What I want to say is that I took the example:
"Show 'View customer'button on each row of Orders List page"

And changed it to: "Show 'EDIT customer'button on each row of Orders List page"
I changed the code the folling way:
Button Server:
$record = $button->getCurrentRecord();

$result["CustomerID"] = $record["CustomerID"];

  1. ClientAfter code
    var win = Runner.displayPopup( {

    url: "customers_edit.php?editid1="+result["CustomerID"],

    width: 700,

    height: 500,

    header: 'View customer'

    });
  2. after record updated

    $pageObject->setProxyValue('saved', true);

    echo "<!doctype html>";
  3. Javascript onload event of Edit page

    if ( (proxy['saved'] ) && window.parent && window.parent.popup ) {

    // close popup

    window.parent.close();

    // refresh list page

    window.parent.location.reload();

    }
    After pressing save I want to close the popup.

    THX!!

    Andreas

admin 10/4/2016

Check #1 code again, you are not using the code I posted here, var win vs window.popup