Welcome to the nuBuilder Forums!

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

delay before nuGetBreadcrumb() Topic is solved

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

delay before nuGetBreadcrumb()

Unread post 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.
kev1n
nuBuilder Team
Posts: 4301
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: delay before nuGetBreadcrumb()

Unread post 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);
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: delay before nuGetBreadcrumb()

Unread post 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');
kev1n
nuBuilder Team
Posts: 4301
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: delay before nuGetBreadcrumb()

Unread post 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,
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: delay before nuGetBreadcrumb()

Unread post 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.
kev1n
nuBuilder Team
Posts: 4301
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: delay before nuGetBreadcrumb()

Unread post by kev1n »

Do you need to call nuGetBreadcrumb() at any case, if there is an error or not?
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: delay before nuGetBreadcrumb()

Unread post 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.
kev1n
nuBuilder Team
Posts: 4301
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: delay before nuGetBreadcrumb()

Unread post 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)
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4301
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: delay before nuGetBreadcrumb()

Unread post by kev1n »

Hi,

Were you able to solve this?
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: delay before nuGetBreadcrumb()

Unread post by kknm »

Your code works... but I've decided that alert() is preferable to ensure that the user is informed.
Thanks !
Post Reply