Page 1 of 1
Open new Record after saving
Posted: Mon Jan 29, 2018 10:22 am
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','', '');
Re: Open new Record after saving
Posted: Mon Jan 29, 2018 12:01 pm
by toms
I just noticed that calling
Code: Select all
nuForm(window.nuFORM.getProperty('form_id'),'-1','', '');
or
keeps adding a new breadcrumb. So, there must be another way...
Re: Open new Record after saving
Posted: Mon Jan 29, 2018 9:21 pm
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
Re: Open new Record after saving
Posted: Mon Jan 29, 2018 11:08 pm
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
}
Re: Open new Record after saving
Posted: Tue Jan 30, 2018 11:10 am
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
Re: Open new Record after saving
Posted: Tue Jan 30, 2018 12:27 pm
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
Re: Open new Record after saving
Posted: Tue Jan 30, 2018 1:31 pm
by admin
toms,
Have you got the latest from GitHub?
It works for me.
Steven
Re: Open new Record after saving
Posted: Tue Jan 30, 2018 1:39 pm
by toms
Steven,
I must have done something wrong while updating. It works now - thank you!
Re: Open new Record after saving
Posted: Tue Jan 30, 2018 1:41 pm
by admin
Cool!