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'm looking for a way to hide a button from the ribbon using javascript, but to do this I need to wait until the elements of the ribbon are loaded.

Is there a way to detect such event?

share|improve this question
    
Any reason why you can not use a HideCustomAction: msdn.microsoft.com/en-us/library/ms414790.aspx –  Robert Lindgren May 17 '13 at 9:10
    
Because I want to hide the Action under some conditions –  must19 May 17 '13 at 9:12
    
Must19, i have similar issue of DOM being not available. How were you able to accomplish this? Thanks –  user21997 Jan 15 at 23:02
add comment

1 Answer

up vote 2 down vote accepted

Here is some js that should load efter the ribbon is loaded:

SP.SOD.executeOrDelayUntilScriptLoaded(function() {
         // Your code here
      },
      "sp.ribbon.js");

More about modifying in this blogpost

Edit:

// Fires ‘ribbontabselected’ after the ribbon has been initialized after load
ExecuteOrDelayUntilScriptLoaded(function () {
var pm = SP.Ribbon.PageManager.get_instance();
pm.add_ribbonInited(function () {
 // Your code here
});
}, ‘sp.ribbon.js’);

from here

share|improve this answer
    
Thanx for the response. I tried this before, but do not garantee that the elements are attached to the dom. –  must19 May 17 '13 at 9:24
    
Well I am not aware of any other events like "ribbon is loaded", so maybee you have to add a small delay in your code just to make sure all is loaded and well –  Robert Lindgren May 17 '13 at 9:28
    
Updated with a more "complex" sample –  Robert Lindgren May 17 '13 at 9:32
    
This worked fine. Thanx for helping –  must19 May 17 '13 at 9:51
add comment

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.