Open new Record after saving

Questions related to using nuBuilder Forte.

Open new Record after saving

Postby toms » Mon Jan 29, 2018 6:52 pm

Hi,

What's the best way to open a new record right after saving the current one?
If there was an AfterSave event (js), I could run this code.

Code: Select all
nuForm(window.nuFORM.getProperty('form_id'),'-1','', '');
toms
 

Re: Open new Record after saving

Postby toms » Mon Jan 29, 2018 8:31 pm

I just noticed that calling

Code: Select all
nuForm(window.nuFORM.getProperty('form_id'),'-1','', '');


or

Code: Select all
nuAddAction();


keeps adding a new breadcrumb. So, there must be another way...
toms
 

Re: Open new Record after saving

Postby admin » Tue Jan 30, 2018 5:51 am

toms,

You almost had it, you just needed one more parameter...

Code: Select all
nuForm(window.nuFORM.getProperty('form_id'),'-1','', '', 1);   //-- fifth parameter


http://wiki.nubuilder.net/nubuilderforte/index.php/Javascript#nuForm

Steven
admin
Site Admin
 
Posts: 3154
Joined: Mon Jun 15, 2009 9:53 am

Re: Open new Record after saving

Postby toms » Tue Jan 30, 2018 7:38 am

Steven,

I override the save button's onClick handler with the following code. However, setting a timeout might not always work reliably since the saving process might take more than 1 second.

Is there a better possibility to detect when the saving is done?
Or could you add a "nuOnSave"-js event that tiggers, as soon as the record has been saved?

Code: Select all
if (nuFormType() == 'edit') {
    $("#nuSaveButton").attr('onclick', '');
    $("#nuSaveButton").click(function() {
        nuSaveAction();
        setTimeout(function() {
            nuAfterSave();
        }, 1000);
    });
}

function nuAfterSave() {
    nuForm(window.nuFORM.getProperty('form_id'), '-1', '', '', 1); // open a new record
}
toms
 

Re: Open new Record after saving

Postby admin » Tue Jan 30, 2018 7:40 pm

toms,

Sorry, but I didn't read your post properly the first time.

I understand what you mean now.

I have added this PHP function...

http://wiki.nubuilder.net/nubuilderforte/index.php/PHP#nuReturnNewRecord

Steven
admin
Site Admin
 
Posts: 3154
Joined: Mon Jun 15, 2009 9:53 am

Re: Open new Record after saving

Postby toms » Tue Jan 30, 2018 8:57 pm

Steven,

It doesn't work for me.

after_save_new_record.png
after_save_new_record.png (8.53 KiB) Viewed 1012 times


All I see, after hitting "save", is a blank message:

msg_blank.png
msg_blank.png (1.48 KiB) Viewed 1012 times
toms
 

Re: Open new Record after saving

Postby admin » Tue Jan 30, 2018 10:01 pm

toms,

Have you got the latest from GitHub?

It works for me.

Steven
admin
Site Admin
 
Posts: 3154
Joined: Mon Jun 15, 2009 9:53 am

Re: Open new Record after saving

Postby toms » Tue Jan 30, 2018 10:09 pm

Steven,

I must have done something wrong while updating. It works now - thank you!
toms
 

Re: Open new Record after saving

Postby admin » Tue Jan 30, 2018 10:11 pm

Cool!
admin
Site Admin
 
Posts: 3154
Joined: Mon Jun 15, 2009 9:53 am


Return to General



cron