Showing Multiple Noty Notifications With a Delay

jquery, mysql, notifications, php

Solution

You could just use the `setTimeout()` native Javascript function. This will queue up an action after a given timeout period (milliseconds).

$(document).ready(function() {
    var noty_id = noty({"text":"a message","layout":"topRight","type":"inormation","animateOpen":{"height":"toggle"},"animateClose":{"height":"toggle"},"speed":1000,"timeout":5000,"closeButton":false,"closeOnSelfClick":true,"closeOnSelfOver":false,"modal":false});
    setTimeout(function() {   var noty_id = noty({"text":"a message","layout":"topRight","type":"inormation","animateOpen":{"height":"toggle"},"animateClose":{"height":"toggle"},"speed":1000,"timeout":5000,"closeButton":false,"closeOnSelfClick":true,"closeOnSelfOver":false,"modal":false}); }, 5000)
});

You may find jQuery Pines a better notification system for queuing up multiple notifications.

Problem

I'm using noty to display notifications using the 'top right' alerts setting. I'm really new to jquery but know php and mysql enough to get most things i want done. What i want to do is use mySQL to get the data to see if a user needs to be shown any notifications (done). Then show that notification on page load, which I've also done, although I'm sure there's a more elegant way to show multiple notifications other than repeating the code? Then i want to put a delay of say 1 second for each notification to appear so they don't all pop up at once, and disappear at the same time. I've looked into .delay() but without knowing jQuery a little better it's pretty useless to me. My code: ``` $(document).ready(function() { var noty_id = noty({"text":"a message","layout":"topRight","type":"inormation","animateOpen":{"height":"toggle"},"animateClose":{"height":"toggle"},"speed":1000,"timeout":5000,"closeButton":false,"closeOnSelfClick":true,"closeOnSelfOver":false,"modal":false}); var noty_id = noty({"text":"a message","layout":"topRight","type":"inormation","animateOpen":{"height":"toggle"},"animateClose":{"height":"toggle"},"speed":1000,"timeout":5000,"closeButton":false,"closeOnSelfClick":true,"closeOnSelfOver":false,"modal":false}); }); ```

Original source