Ribbon Buttons always disabled

Feb 28, 2013 at 6:29 PM
Hi,

thanks for this usefull project. Trying out the demo web part in SP 2013 I notice that all buttons are disabled no matter what I do. Additionally, clicking the Browse tab does not display the original content once another tab has been clicked. It is just a white canvas.

Do you have any ideas what is going on?

Thanks!
Coordinator
Mar 19, 2013 at 7:36 AM
Hi,

Buttons or other ribbon elements may be disabled 'cause of there is a client script error on a page.

Try set any OnClient* properties to string.Empty and check your page again.
Apr 2, 2013 at 1:30 AM
Hey. So, I'm having the opposite problem. My buttons are always enabled. When I tried to disable one (for example, an Edit button that should only be enabled when something in a list is checked), nothing happens.

I tried this:
                     new RibbonButton("Edit", "Edit")
                    {
                        Image = new RibbonImageDefinition( ) { Url32 = "http://server/_admin/images/edit32x32.png" },
                        OnClientClick = "javascript:window.location = 'http://server/_admin/pages/home.aspx'",
                        OnClientStateCheck = "return EnableButton('edit');"
                    },
Here is the script:
<script type="text/javascript">
    function EnableButton( type )
    {
        alert( type );
        if ( type == "edit" )
        {
            return false;
        }

        return true;
    }
</script>
This is for SharePoint 2010, by the way. I put the alert(type) to see if it was even getting called and it's not. I noticed in the generated html you have this:

function commandEnabledMyRibbon(commandId)
{
if (commandId == 'Ribbon.MyRibbon.Manage.Controls.EditCommand') { return true; }
if (commandId == 'Ribbon.MyRibbon.Manage.Controls.EditCommand') { ; return EnableButton('edit');; return true;; }
return false;
}

Also, this:

function handleCommandMyRibbon(commandId, properties, sequence)
{
if (commandId == 'Ribbon.ExpertClearView.Manage.Controls.EditCommand') { javascript:window.location = 'http://myserver/_admin/pages/home.aspx'; ; return true; }
if (commandId == 'Ribbon.ExpertClearView.Manage.Controls.EditCheckState') { ; return EnableButton('edit');; return true;; return true; }
return false;
}

Wouldn't the first "if (commandId == 'Ribbon.MyRibbon.Manage.Controls.EditCommand')" mean my code on the second line is never being called?

Any thoughts? Thanks!
Coordinator
Apr 18, 2013 at 1:42 AM
This bug is fixed in the new release (14.2, 15.2).
Thank you for your feedback!
Apr 22, 2013 at 8:34 PM
I'll try to check it out this week.

Thank you!