Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Open new Record after saving Topic is solved

Questions related to using nuBuilder Forte.
Post Reply
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Open new Record after saving

Unread post by toms »

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
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: Open new Record after saving

Unread post by toms »

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...
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Open new Record after saving

Unread post by admin »

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/nubuilderfort ... ipt#nuForm

Steven
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: Open new Record after saving

Unread post by toms »

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
}
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Open new Record after saving

Unread post by admin »

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/nubuilderfort ... nNewRecord

Steven
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: Open new Record after saving

Unread post by toms »

Steven,

It doesn't work for me.
after_save_new_record.png
All I see, after hitting "save", is a blank message:
msg_blank.png
You do not have the required permissions to view the files attached to this post.
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Open new Record after saving

Unread post by admin »

toms,

Have you got the latest from GitHub?

It works for me.

Steven
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: Open new Record after saving

Unread post by toms »

Steven,

I must have done something wrong while updating. It works now - thank you!
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Open new Record after saving

Unread post by admin »

Cool!
Post Reply