5

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?

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

1 Answer 1

7

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

4
  • Thanx for the response. I tried this before, but do not garantee that the elements are attached to the dom.
    – must19
    Commented May 17, 2013 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 Commented May 17, 2013 at 9:28
  • Updated with a more "complex" sample Commented May 17, 2013 at 9:32
  • This worked fine. Thanx for helping
    – must19
    Commented May 17, 2013 at 9:51

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.