Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am sending a variety of notifications via

SP.UI.Notify.addNotification("blah", true);

setting the "sticky bit" to true so that the notification stays visible. When I display a second notification, I want to remove the current notification, but I need the id of the notification to remove it with

SP.UI.Notify.removeNotification(id)

Is there any way to remove all of the current notifications or to get the ids of the the current notifications?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

I had the same requirement as you on my last project and used the same approach that you did:

[Edit- moved from within question]

var currentNotificationID = "";

function replaceNotification(message) {

    if(currentNotificationID != "") {
        SP.UI.Notify.removeNotification(currentNotificationID);
    }

    currentNotificationID = SP.UI.Notify.addNotification(message, true);

    return;
}

function showError() {

    replaceNotification('Error message...');

    return;
}

[End Edit]

The API doesn't offer the method you're looking for on the SP.UI.Notify class.

It does however offer this method on the SP.UI.Status class:

SP.UI.Status.removeAllStatus(true);

Would this be an acceptable alternative? Click Here for more MSDN documentation on the SP.UI.Status class.

share|improve this answer
    
I was asked to use Notify over Status, but the above worked well enough for what I needed. I added this solution to your answer and will mark accepted once my edit gets peer reviewed. Feel free to change it. –  xdhmoore Nov 23 '11 at 18:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.