Page 1 of 1

Sub-Tab focus from Display to Edit form

Posted: 30 Jun 2015
by holtonba
We have a form that contains parent tabs with child (sub-tabs) inside the parent to help organize the information. Is there a way to maintain the focus on the tab that was activated on the Display Form when opening up the Edit Form?

For example, user navigates to the Display form and clicks on parent Tab B and Subtab 3. If the user clicks Edit to open up the respective edit form, can it automatically activate parent Tab B, Subtab 3?

Re: Sub-Tab focus from Display to Edit form

Posted: 02 Jul 2015
by rostislav
Add the following code to your form (for all view types where you want to have this functionality: Display, Edit, New?)

Code: Select all

var contextID = _spPageContextInfo.pageListId+':'+GetUrlKeyValue('ID');

for (id in fd_tabcontrol_ids){
        if (typeof $.cookie("#"+fd_tabcontrol_ids[id]+":"+contextID) !== 'undefined') {
                 $("#"+fd_tabcontrol_ids[id]).tabs('option', 'active', $.cookie("#"+fd_tabcontrol_ids[id]+":"+contextID));
        };
        $.cookie("#"+fd_tabcontrol_ids[id]+":"+contextID, $("#"+fd_tabcontrol_ids[id]).tabs('option', 'active'));
        $("#"+fd_tabcontrol_ids[id]).on( "tabsactivate", function( event, ui ) {
                if(this === event.target)
            {
                        $.cookie('#'+event.currentTarget.id+':'+contextID, ui.newTab.index());
            }
        } );
}