getNotifications

Returns a jQuery collection of all visible notifications, displayed by the given widget instance. Each item in the collection is a div.k-notification element.

This method is useful for quick removal of all visible messages before showing new ones. After obtaining all visible messages, remove them from the DOM instead of hiding them, unless animations are disabled. This is because animations are asynchronous and the new messages will be shown on the wrong places before the old ones have been hidden. Another thing to keep in mind is that when using popup notification messages, you should remove the parent of each member of the collection, returned by the getNotifications() method. In this case the parent will be a div.k-animation-container element.

Example

<span id="notification"></span>
<button id="removeMessages" type="button" class="k-button">Remove messages and show new ones</button>

<script>

var notificationWidget = $("#notification").kendoNotification({
    button: false,
    hideOnClick: false,
    autoHideAfter: 0
}).data("kendoNotification");

var messageCount = 1;

notificationWidget.show("foo " + messageCount);
notificationWidget.show("bar " + messageCount);

$("#removeMessages").click(function(){
    // since there is no way for the user to hide notifications,
    // the following expression will return two elements, no matter when it is executed
    var elements = notificationWidget.getNotifications();

    // remove the two messages from the DOM
    elements.each(function(){
        $(this).parent().remove();
    });

    messageCount++;

    // show two new messages
    notificationWidget.show("foo " + messageCount);
    notificationWidget.show("bar " + messageCount);
});

</script>

Returns

jQuery A collection of all visible notifications.

In this article