0

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 = @"
      ExecuteOrDelayUntilScriptLoaded(function(){{
         ExecuteOrDelayUntilScriptLoaded(function(){{
             var statusId = SP.UI.Status.addStatus('{0}');
               SP.UI.Status.setStatusPriColor(statusId, '{1}');
               setTimeout(function(){SP.UI.Status.removeStatus(statusId);}, 2000);
               }},
           'core.js'
            )}},
        'sp.js'
        );";

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

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

1 Answer 1

2

This can be achieved by simply using the setTimeout function.

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

    setTimeout(function(){
     SP.UI.Status.removeStatus(statusID);
    }, 2000);
3
  • 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 Jun 9, 2014 at 3:01
  • Can you post your new code. Jun 9, 2014 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 Jun 9, 2014 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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