Sharepoint - Items And List Tabs In Ribbon Don't Show After Editing Page
This is not a bug. If you have more than one web part on a page then you must click the one you want the ribbon for.
Apparently, this is a common problem (I'm surprised that nobody already had a custom solution).
Apparently, this is what causes the problem:
When you add a web part to the standard list views, the page is no longer classified as a list view page, but instead it is classed as an application page.
Katrina over on Stack Exchange posted this solution.
setTimeout(function() {
var elem = document.getElementById("MSOZoneCell_WebPartWPQ2");
if(elem != null) {
var dummyevent = new Array();
dummyevent["target"] = elem;
dummyevent["srcElement"] = elem;
WpClick(dummyevent);
_ribbonStartInit("Ribbon.Browse", true); //set the Browse button as default
}
}, 2000);
This method will display the tabs above the ribbon, but the problem is that if you click on the page anywhere besides the ribbon itself or in the list, then the tabs disappear again, so it's not perfect, but it is sort of a workaround.
I tried the above function without the timeout, and with _spBodyOnLoadFunctionNames.push(whatfunction);
instead, and it seemed to work fine except that the ribbon is quickly opened and close on page load.
Use the designer and put the code in the Content PlaceHolderAdditionalPageHead
@Colbs on StackExchange: Question on StackExchange