Search code examples
javascriptjquerytoast

how to set display time of ToastMessage?


  setTimeout(function () { showToastMessage("Guest added successfully test2").fadeOut(4000);});

I want to display this message up to 5 sec. but i don't know how to set the display time. I know how to set the delay time. i have used .fade Out method but its not working. i am still in trouble. help me

I want to display this message up to 5 sec. but i don't know how to set the display time. I know how to set the delay time. i have used .fade Out method but its not working. i am still in trouble. help me


Solution

  • I don't know how work showToastMessage function, but it's looks like this function return jQuery object, so you can use .delay method

    showToastMessage("Guest added successfully test2")
        .delay(5000)
        .fadeOut(4000);
    

    or without jQuery magic you can save jQuery toast object and call fadeOut after timeout

    var $toast = showToastMessage("Guest added successfully test2");
    setTimeout(function(){
        $toast.fadeOut(4000);
    }, 5000);