How to access my controls in JavaScript

Add-in Express™ Support Service
That's what is more important than anything else

How to access my controls in JavaScript
I need to disable/enable my buttons, how to do this 
This forum has moved to a new location. From now on, please post all your questions about Ribbon Designer for SharePoint on this forum.
Alver R.




Posts: 5
Joined: 2012-01-11
I have a toggle button and another buttons, the buttons are disabled by default. I want to enable them if the first button is toggled. Can you give me an example please?
Posted 18 Jan, 2012 10:52:17 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Alver,

In JavaScript, you can use the same names that you set to your controls in Visual Studio and almost the same properties and methods. Please have a look at the code sample below:

SPRibbonProject4.Features.SPRibbon1.SPRibbon1.prototype.adxspRibbonToggleButton1OnClick_EventHandler = function (sender) {

    // sender is ADXSPRibbonToggleButton
    if (sender.Pressed) {
        this.adxspRibbonButton1.Enabled = true;
        this.adxspRibbonButton2.Enabled = true;
        this.adxspRibbonButton3.Enabled = true;
    }
    else {
        this.adxspRibbonButton1.Enabled = false;
        this.adxspRibbonButton2.Enabled = false;
        this.adxspRibbonButton3.Enabled = false;
    }
    // refresh UI
    this.RefreshRibbon();
}


This is the OnClick event handler of an ADXSPRibbonToggleButton control. The code enables or disables 3 additional buttons (named adxspRibbonButton1, adxspRibbonButton2 and adxspRibbonButton3 in my case) depending on the Pressed property. Additionally, the RefreshRibbon method is called to refresh controls.

You can find more details about objects, their properties and methods that can be accessed in JavaScript in the "The Ribbon Designer JavaScript client object model" chapter of the Ribbon Designer Class Reference.
Posted 18 Jan, 2012 11:24:40 Top