0

On my Webpart page there is a Content Editor and a ListView Webpart and the Content Editor is on top.

I want to hide the "New" section in the ribbon that goes with the listview.

The problem is that the ribbon for the listview does not load until you click into the listview itself. Since the Content Editor comes first on the webpart page, the initial ribbon pertains to it. The listview's ribbon does not appear until you click into the listview.

This means that when you run functions in document.ready they fire before the listview ribbon appears.

How can I hide the New Item button in the listview's ribbon? So far I have tried this (the click event works), both with and without the timeout:

$("#MSOZoneCell_WebPartWPQ4").click( function(){
    console.log("The Listview!");
    //$("#Ribbon.ListItem.New").hide();
    //$("#Ribbon.ListItem.New.ms-cui-group").addClass("hiddenpart");
    setTimeout( function(){
        $("li#Ribbon.ListItem.New").hide();
    },500);
});

And I tried this:

    $("head").append("<style type='text/css'>#Ribbon\.ListItem\.New\.NewListItem-Large{ display:none; }</style>"); 
1

Well, I found this, which will prevent the List Tools from appearing when you click into the listview webpart! That's even better.

$(".s4-wpcell").removeAttr('onkeyup').removeAttr('onmouseup');

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.