Load one informational message after another after x seconds

0

I have a part of my code that I would like to modify. I'm sending to print  and I show a message, what I want to do is that after 5 seconds show me another informative message and, after 3 more seconds, disappear and follow the flow of the program.

The code:

    $(function() {
        renderTexts();
        renderButtons(['entrar','salir']);		

$("#boton-confirmar").get(0).clickCallback = function () {
            alert_UI('Aguarde un instante mientras se imprime el ticket', 'Imprimiendo', 'loading');
            return false;
        };

The message I want to show after 5 seconds and disappear after 3 seconds would be:

alert_UI('Tome su ticket y entréguelo en ventanilla ', 'Canjes', 'loading');

I tried linking but without success. Thanks!

    
asked by look68 16.01.2017 в 17:20
source

1 answer

0

It's as simple as displaying messages within window#setTimeout .

function alertUI(message, title, status, delayShow, delayHide) {
  window.setTimeout(function () {
    // mostrar mensaje
    window.setTimeout(function () {
      // esconder mensaje
    }, delayHide);
  }, delayShow);
}

You would use it like this:

alert_UI('Tome su ticket y entréguelo en ventanilla ', 'Canjes', 'loading', 5000, 3000);

Regarding:

  

and follow the flow of the program

In JavaScript there is no way to "sleep" the thread like in other languages. Remember that JavaScript is an asynchronous language.

    
answered by 16.01.2017 в 17:49