I have some code that creates a new status bar but it just stays on top without fading. It doesn't even have an 'x' to close it manually. The following is how I am adding a new SP status from code behind. How can I make this fade out after a couple seconds? jQuery? Am I missing an argument that allows the status to be closed?

var scriptTemplate = @"
             var statusId = SP.UI.Status.addStatus('{0}');
               SP.UI.Status.setStatusPriColor(statusId, '{1}');
               setTimeout(function(){SP.UI.Status.removeStatus(statusId);}, 2000);

var script = string.Format(scriptTemplate, message.Replace("\"", "\\\""), color);

Page.ClientScript.RegisterClientScriptBlock(typeof(MyTrainingUserControl),  "notifysuccess", script, true);

This can be achieved by simply using the setTimeout function.

    var statusID = SP.UI.Status.addStatus('bold text', 'message');

    }, 2000);
| improve this answer | |
  • thanks! I can't get this working with my code above. I tried putting setTimeout(function(){ SP.UI.Status.removeStatus(statusID);}, 2000); right after .setSTatusPriColor but it breaks – Michael Colbs Jun 9 '14 at 3:01
  • Can you post your new code. – user3647439 Jun 9 '14 at 5:34
  • See OP. I just added the setTimeout line. also tried moving it outside the other functions and making the inner func call a new one – Michael Colbs Jun 9 '14 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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