Page 1 of 1

delay before nuGetBreadcrumb()

Posted: Wed Apr 13, 2022 12:26 pm
by kknm
On the form, using php, I make a request to the database 1. If the data is received, I write it to another database 2. Using js, I fill the table from
database 2 on the same form, save the form and update with nuGetBreadcrumb() on the ssame button with php-procedure.
Task: If data is not received, display a message for the user.
Problem:
nuDisplayError displays a message for a very short time because nuGetBreadcrumb() fires.
nuJavascriptCallback() does not display this message at all for the same reason.
How to make a delay before nuGetBreadcrumb() in case of an empty database request.

Re: delay before nuGetBreadcrumb()

Posted: Wed Apr 13, 2022 12:30 pm
by kev1n
Hi,

Use JS setTimeout()

Code: Select all

var delayInMilliseconds = 1000; //1 second

setTimeout(function() {
  //your code to be executed after 1 second
   nuGetBreadcrumb();
}, delayInMilliseconds);

Re: delay before nuGetBreadcrumb()

Posted: Wed Apr 13, 2022 12:45 pm
by kknm
Where to place this code?
On my button, it's already implemented like this:
onclick - nuRunPHPHidden('DB'); nuGetBreadcrumb(); nuMessage(['Wait...']);
onclick - getCurrentTime('#konv_vr');

Re: delay before nuGetBreadcrumb()

Posted: Wed Apr 13, 2022 12:49 pm
by kev1n
nuRunPHPHidden() is executed asynchronous, that means nuGetBreadcrumb(); is usually called before nuRunPHPHidden() has finished executing.

The way to go is to run nuRunPHPHidden() and call nuJavascriptCallback() within the PHP code that executes nuGetBreadcrumb(); etc,

Re: delay before nuGetBreadcrumb()

Posted: Wed Apr 13, 2022 2:32 pm
by kknm
Unfortunately the code does not work as expected.
The visibility of nuMessage and nuDisplayError is very low to read the message.
As an alternative, I applied alert via nuJavascriptCallback.

Re: delay before nuGetBreadcrumb()

Posted: Wed Apr 13, 2022 4:03 pm
by kev1n
Do you need to call nuGetBreadcrumb() at any case, if there is an error or not?

Re: delay before nuGetBreadcrumb()

Posted: Thu Apr 14, 2022 5:02 pm
by kknm
nuGetBreadcrumb() in any case, it must be applied, because i need to save the time of button click. It could be that nuSaveAction() applied on the same button prevents the nuMessage from being displayed for a long time. It does not give errors according to your code, but as I said, the message display is very short.

Re: delay before nuGetBreadcrumb()

Posted: Thu Apr 14, 2022 5:12 pm
by kev1n
I tested it with this Procedure and the message is shown for 3 seconds before the form is refreshed.

msgtest.png

Code: Select all

nuRunPHPHidden('msgtest',0)

Re: delay before nuGetBreadcrumb()

Posted: Wed Apr 20, 2022 4:01 pm
by kev1n
Hi,

Were you able to solve this?

Re: delay before nuGetBreadcrumb()

Posted: Thu Apr 21, 2022 8:56 am
by kknm
Your code works... but I've decided that alert() is preferable to ensure that the user is informed.
Thanks !