Using timeouts with toastr

Merlin picture Merlin · Nov 10, 2013 · Viewed 7.7k times · Source

Most of the toastr demos are client side only.

If I get a server push of this json data

   [
    {"msg": "Mortgage bill paid", "t": "i"}
    {"msg": "Account Balance below $3000", "t": "i"}
    {"msg": "Received Car payment request", "t": "w"}
    ]

How would I use toastr read through items and publish 'info' for 1 and 2, "warning" for 3, lower right is ok. I would like a delay of 2000 between toasts so the toast dont come at the same time.

Can you point me to example that show something similar. Can toastr do this. Timed messaging in a sense.

Answer

hafiz ali picture hafiz ali · Sep 30, 2015

This is the exact thing you need I guess

setTimeout((function() {
   toastr.info('MESSAGE TITLE', 'message content', {options});
}), delay);

toastr.options = {
  "closeButton": true,
  "debug": false,
  "newestOnTop": false,
  "progressBar": false,
  "positionClass": "toast-top-center",
  "preventDuplicates": false,
  "onclick": null,
  "showDuration": "300",
  "hideDuration": "1000",
  "timeOut": "5000",
  "extendedTimeOut": "1000",
  "showEasing": "swing",
  "hideEasing": "linear",
  "showMethod": "fadeIn",
  "hideMethod": "fadeOut"
}