1

The default Add/Edit Item dialog for a custom list allows you to double-click on the Edit ribbon tab to minimize/collapse the action button row for the ribbon. I would like to be able to have a little bit of JavaScript on the form that hides those buttons by default. This is causing some confusion for some users as they also see the Approve button for publishing when they are being instructed to "approve" a custom workflow item.

If I have double-clicked to hide the ribbon tab container, I can bring it back with the following sample jQuery code:

$("span.ms-cui-tt-span").click();

Despite my best efforts to simulate a double click, I can't seem to get it to fire. None of these work properly:

$("span.ms-cui-tt-span").dblclick();
$("span.ms-cui-tt-span").trigger("dblclick");
$("span.ms-cui-tt-span").trigger("doubleclick");
$("span.ms-cui-tt-span").trigger("click").trigger("click");
$("span.ms-cui-tt-span").click(); $("span.ms-cui-tt-span").click();

I may try to use the profiler and see if I can unwind through the stack and get some better info. It looks like OnRibbonMinimizedChanged is called at some point in the process and that may give some good clues as well.

Here are two screenshots. The first showing the normal ribbon in the add new item dialog and the second showing the result of double clicking on the Edit ribbon tab and collapsing the action area under the tab:

SharePoint 2010 Add New Item Dialog Normal Ribbon

SharePoint 2010 Add New Item Dialog Collapsed Ribbon From Double Click

  • Maybe I misunderstood the question but what you are trying to do is to hide the EDIT button when the users double clicks on it and when double click again to show it again? – Alvmad Oct 3 '13 at 6:51
  • No, I don't want to hide the edit button. I want to use the built in functionality that already exists - open a new item dialog (it has to be the dialog version for this to work for some reason) and double click on any of the ribbon tab headers. It will collapse the space beneath them and hide all the action buttons. I want to trigger that behavior on form load to have it collapsed by default - but easily restored by clicking on the tab header. All stock, out of the box behavior except for simulating the double-click event. – Goyuix Oct 3 '13 at 16:24
2

Just doing a proof concept you can put this code in the NewForm Web Part adding a content editor web part

 $( document ).ready(function() {
    $(".ms-cui-tabContainer").remove();
    $("#s4-ribbonrow").css('height','35px');
    $("#s4-titlerow").attr('class','ms-dialogHidden');
    $("#s4-titlerow").css('display','block');
    });

This worked for me

  • Thanks. I tried a few iterations of something similar but this works pretty well. The only issue is that it takes quite a few clicks to get the default behavior back: double click to "hide" and change the tab look as well one more click to bring it back. – Goyuix Oct 3 '13 at 17:42
  • Yes you are right.I didn't manage other way to do it – Alvmad Oct 4 '13 at 5:46

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.