Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery notifications stack to slide out one by one
    primarykey
    data
    text
    <p>I want to create notifications so that when something is saved on page or some error happens a notification appears saying the results.</p> <p>HTML and JQuery both work fine they stack up so if 3 notifications happen at the same time all 3 slide in but when it comes fading them out within 5 seconds only the top one slides out.</p> <p>Here is the JQuery code:</p> <pre><code> var notificationsQueue = []; function createNotification(text) { $obj = $('&lt;div&gt;' + '&lt;div class="notification animated"&gt;' + '&lt;div class="notification-left-container"&gt;' + '&lt;div class="notification-icon"&gt;&lt;/div&gt;' + '&lt;/div&gt;' + '&lt;div class="notification-right-container"&gt;' + '&lt;div class="notification-right-inner-container"&gt;'+text+'&lt;/div&gt;' + '&lt;/div&gt;' + '&lt;div class="notification-clear-both"&gt;&lt;/div&gt;' + '&lt;/div&gt;' + '&lt;/div&gt;').prependTo('#notifications_list div.notifications-pusher'); $obj.show('slide', { direction: 'left' }, 500); notificationsQueue.push($obj); } </code></pre> <p>now above code displays notifications on top of each other. When it comes to slide them out I use the following code:</p> <pre><code>setInterval(function() { if (notificationsQueue.length) { $obj = notificationsQueue.pop(); setTimeout(function() { $obj.hide('slide', { direction: 'left' }, 500); }, 3000); } }, 500); </code></pre> <p>so every <strong>half</strong> a second it checks if notifications queue is empty if not then pop the last one and slide out in 3 seconds. Above code only slides out the top div and not the rest of them. Rest of them stay on page.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload