This topic is locked

Add popup - open a new add popup page after saving

8/27/2011 5:57:50 AM
PHPRunner General questions
J
jomppa10 author

Hi,
using 5.3 7474 version I am trying to add the following functionality from my clients request:

using add popup page, when a user adds new records he can either

  • save and close popup window
  • or save and continue adding records when clicking "Save and add new" button.
    Here is what I have done so far after some searching:
    1.New button to a add page:
    <INPUT id=submit2 value="Save and Add new" type=button name=submit2>
    2.Javascript onload event for a add page:
    $("#submit2").bind("click", {page: this}, function(e){
    var page = e.data.page;
    page.on('beforeSave', function(formObj, fieldControlsArr, pageObj){

    formObj.baseParams['submit2'] = 'Save and Add new';

    }, page, { single: true});

    page.on('afterSave', function(respObj, formObj, fieldControlsArr, pageObj){

    delete formObj.baseParams['submit2'];

    }, page, {single: true});
    page.saveHn(e);

    $("#addButton"+1).click(); // opens a new add popup page, 1 is a pageid for a list page
    }
    );
    This approach seems to work in simple add popup pages but not if there is also child records from a detail table included. These child records are not saved and also a new add popup page is not opened.
    So, I wonder if somebody can help and give some examples how to proceed.
    Regards

    Jouni I

C
cgphp 8/27/2011
var pageObj = Runner.pages.PageManager.getAt('your_table_name', pageid);
$("#submit2").click(function(e){

$("#saveButton"+pageid).click();

pageObj.on('afterSave', function(formObj, fieldControlsArr, pageObj){

$("#addButton"+1).click();

});

});
J
jomppa10 author 8/27/2011


var pageObj = Runner.pages.PageManager.getAt('your_table_name', pageid);
$("#submit2").click(function(e){

$("#saveButton"+pageid).click();

pageObj.on('afterSave', function(formObj, fieldControlsArr, pageObj){

$("#addButton"+1).click();

});

});



Thank you Christian for a quick reply!
This works for normal add popup pages.
For pages that have child records included all records are now saved but a new add popup page is not showing up.
Something to do with generated pageids?
regards
Jouni I

C
cgphp 8/27/2011

It seems a issue related to the afterSave event. Try out this code without the afterSave event:

$("#submit2").click(function(e){

$("#saveButton"+pageid).click();

$("#addButton"+1).click();

});
J
jomppa10 author 8/27/2011



It seems a issue related to the afterSave event. Try out this code without the afterSave event:

$("#submit2").click(function(e){

$("#saveButton"+pageid).click();

$("#addButton"+1).click();

});



Hi,
now a new add popup opens on the front but the saved popup(s) stays behind it (not closing).
I tried to attach a picture but didn't know how to do it.
Jouni I

C
cgphp 8/27/2011

It works for me. Is it the only one js code in the "Javascript OnLoad" event ?

J
jomppa10 author 8/27/2011



It works for me. Is it the only one js code in the "Javascript onload" event ?


Yes. Here is the link to show the behaviour.

J
jomppa10 author 8/27/2011



Yes, I'm using child records in the add popup, me too.


I made some tests with pure phprunner files and you are right . I have to check my modified project files once again.
This is a good asset for all of us and also a nice new feature to manage records.

Thanks again.
regards

Jouni I

J
jomppa10 author 8/27/2011



I made some tests with pure phprunner files and you are right . I have to check my modified project files once again.
This is a good asset for all of us and also a nice new feature to manage records.

Thanks again.
regards

Jouni I


Hi again,
some more tests with a pure phprunner 7474 project.Whenever you use child tables in a add popup page, occurs the same as above picture: the old popups stacks under the new empty popup page. Thats why I did not notice this at first.
The only event in the whole project is
Javascript onload (add page):
$("#submit2").click(function(e){

$("#saveButton"+pageid).click();

$("#addButton"+1).click();

});

When I remove the master-detail connection or not use child tables in add popup pages the code works perfectly.
So maybe I need to call addButton from a list page somehow after a new record is added.
regards
Jouni I

C
cgphp 8/28/2011

You are right. I'm investigating it.