Using jQuery to change to the Items tab in a SharePoint 2010 list.

In my last post, I showed how to use a query string parameter to start a user out on the items tab of a SharePoint list. This is well documented, I just can’t seem to remember it (that is why I posted it!). I wanted to take it a step further and use jQuery to change to the Items tab. Here is the code to do that:

$(document).ready(function () {
    ExecuteOrDelayUntilScriptLoaded(function () {
          _ribbonStartInit("Ribbon.ListItem", false, null);
    }, "sp.ribbon.js");    
});

The trick was to make sure the sp.ribbon.js script was loaded, and then use the included function to change to the preferred tab. Hope that helps someone.

,

Comments are closed.