The alerts do not disappear



  • Hello everyone, I am launching alerts from JavaScript depending on the response from a server to which I make a request, as each response I throw a different alert and I need this alert to only spend some time on the air and then disappear.

    As I read in the documentation there is the property duration, but I use it and when testing the alert it remains there only until I close it, but it is not exactly what I need.

    I create the alerts as follows:
    0_1516357114074_d053ccc7-75a5-4a57-9099-147b7e26b199-image.png

    I would expect that after the alert appeared, it would remain on the screen for five seconds and then disappear, but this does not happen.

    Thanks for reading, I hope someone can help me



  • Hello!

    Per the docs, duration determines the time it takes to transition, not how long the alert should stay open. Either use setTimeout() or use Toast



  • I solved this using the setTimeout method as you recommend me in the following way.

    0_1516742923634_8d4385be-cda8-4b0e-85f5-b1d7798e8c59-image.png

    It works in the following way

    Gif in imgur

    Thanks, I think this could be in the documentation. no matter how simple it is, it would help more than one.