In SharePoint 2013, I'm trying to figure out how to hide or disable the Cancel button in the ribbon for the default form (NewForm) for a document library. Looking at the form source, I think this is the HTML element I'm after (ID of Ribbon.DocLibListForm.Edit.Commit.Cancel-Large):
<a class="ms-cui-ctl-large" id="Ribbon.DocLibListForm.Edit.Commit.Cancel-Large" onclick="return false;" href="javascript:;" mscui:controltype="Button" aria-describedby="Ribbon.DocLibListForm.Edit.Commit.Cancel_ToolTip" role="button" unselectable="on"><span class="ms-cui-ctl-largeIconContainer" unselectable="on"><span class=" ms-cui-img-32by32 ms-cui-img-cont-float ms-cui-imageDisabled" unselectable="on"><img class="" style="top: -511px;left: -273px;" unselectable="on" src="/_layouts/15/1033/images/formatmap32x32.png?rev=23"/></span></span><span class="ms-cui-ctl-largelabel" unselectable="on">Cancel</span></a>
I've tried various forms of the jQuery code:
$('#Ribbon.DocLibListForm.Edit.Commit.Cancel-Large').hide();
But that doesn't seem to have any effect. I believe I'm able to actually locate the object in the DOM because the code snippet:
var myObj = $('#Ribbon.DocLibListForm.Edit.Commit.Cancel-Large');
alert("myObj="+myObj);
... does populate the variable with an object. Also, I tried the .disable() method which interestingly resulted in the error "Object doesn't support property or method 'disable'", so that also leads me to believe I'm able to find the element ... just not hide it.
I've seen server-side solutions to accomplish this posted here, but I'm limited to coming up with something in JavaScript. Any advice is appreciated.
$(object).toggle()