3

I am trying to access the ribbon button via JavaScript. Below is my code:

// Get the page manager
var ribbonPageMgr = SP.Ribbon.PageManager.get_instance();
// Get the ribbon
var ribbon = ribbonPageMgr.get_ribbon();

// Get the tab in which button resides
var ribbonTab = ribbon.getChild("Ribbon.List"); // CUI.Tab
// Get the group in tab in which button resides
var ribbonGroup = ribbonTab.getChild("Ribbon.List.Settings"); // CUI.Group

In my case the ribbon button resides in the "List" tab under the "Settings" group. But I am stuck after this point. From whatever resources I could find on the web I have come to conclusion that a ribbon button resides in following containers:

CUI.Tab --> CUI.Group --> CUI.Layout --> CUI.Section

How do I proceed to find CUI.Layout, CUI.Section and eventually my ribbon button? Is this the correct way that I am following?

  • What exactly you want to do with the Ribbon button.? you can find the button by using only jquery (need not use sp.js) and you can hide/show, rename, any other operation etc.. Read below post , might be helpful for you. How-to-hide-ribbon-in-sharepoint using jquery – Vikas Kottari Feb 18 '15 at 7:03
  • @Vikas: My intention is to get the custom ribbon button object and set its properties like ToolTipTitle, ToolTipDescription and more. These properties need to be set dynamically. Can this be done via jQuery? – Naveen Feb 19 '15 at 6:27
0

Actually it is not working as you expect. After investigating it, please look at the DOM with developer tools. Basically the group is a li tag. After that, if you want to make it work you must get as many childs as needed following all span id's.

0

In CUI.Group you can look into $6_0, then $1j_0, where you can find also the CUI.Layout stored in $4_0.

After that, just add .getChild on your CUI.Group with the name of your CUI.Layout.
The same is for CUI.Section.

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.