6

I have a custom GUI extension working that lets me override the Save command (see Rob's article http://www.curlette.com/?p=913).

Ideally I want to hide the button altogether when in the Component UI view - for which there does appear to be a doHide() method on the Tridion.Controls.RibbonButton itself which works well when I tested in Chrome Dev Tools.

What I can't figure is how to get to the Save button in order to call doHide()?

The following gives me all the controls on the ribbon bar

$display.getWindow().$controls.controls["Tridion.Controls.RibbonButton"]

Of which an object called UID_63 is the Save button:

enter image description here

So this works:

$display.getWindow().$controls.controls["Tridion.Controls.RibbonButton"].UID_63.doHide();

But there must be a nicer way than knowing that UID number?

There is a hasControl() method but I can only ever get false out of it:

$display.getWindow().$controls.hasControl("SaveBtn");

And the getControl() method seems to be for adding new controls, not getting current ones?

$display.getWindow().$controls.getControl(n, f, i);

Cheers

3
  • You could iterate all the controls like this: var controls = $display.getView().getWindow().$controls.getAllControls("Tridion.Controls.RibbonButton"). And then: for (var key in controls) { var id = controls[key].getId(); if (id == "SaveBtn") { controls[key].doHide(); } } I'm sure there's a more elegant way to solve this, but this might be a good start Commented Mar 30, 2018 at 17:28
  • And yes, there is indeed: $display.getView().getWindow().$controls.getControl($("#SaveBtn"), "Tridion.Controls.RibbonButton").doHide() :) Commented Mar 30, 2018 at 17:39
  • Thanks Albert - it appeared to be the passing of the param as $("#SaveBtn") was something I missed. Make that at answer and I'll accept it.
    – Neil
    Commented Apr 5, 2018 at 8:22

1 Answer 1

3

You can get a hold of the Save Button like this:

$display.getView().getWindow().$controls.getControl($("#SaveBtn"), "Tridion.Controls.RibbonButton").doHide()

1

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.