Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // for tab 1
- aria-selected="{!$CurrentPage.parameters.selectedTab == 'tab1' ]}"
- <li class="slds-tabs--scoped {!IF( $CurrentPage.parameters.selectedTab == 'tab1', 'slds-active', '' )}" id="tab1" role="presentation">
- <a href="javascript:void(0)" onclick="setSelectedTab( 'tab1' )" role="tab" aria-selected="{!$CurrentPage.parameters.selectedTab == 'tab1'}" class="slds-tab--scoped__link">Tab 1</a>
- </li>
- <li class="slds-tabs--scoped {!IF( $CurrentPage.parameters.selectedTab == 'tab1', 'slds-active', '' )}" id="tab2" role="presentation">
- <a href="javascript:void(0)" onclick="setSelectedTab( 'tab1' )" role="tab" aria-selected="{!$CurrentPage.parameters.selectedTab == 'tab2'}" class="slds-tab--scoped__link">Tab 2</a>
- </li>
- ...
- String selectedTab { get; set; }
- public PageReference changeTab(){
- ... do your DML work here ...
- PageReference pg = Page.CurrentPage;
- pg.getParameters().put( "selectedTab", selectedTab );
- pg.setRedirect( true );
- return pg;
- }
- <script>
- var j$ = jQuery.noConflict();
- // get the tab value from the URL
- var urlParameter = function getURLParam( param ){
- var pageUrl = decodeURIComponent( window.location.search.substring( 1 )),
- urlVars = pageUrl.split( "&" ),
- parmName;
- for( var i = 0; i < urlVars.length; i++ ){
- parmName = urlVars[ i ].split( '=' );
- if( parmName[ 0 ] === param ){
- return ( parmName[ 1 ] === undefined ? "tab1" : parmName[ 1 ] ); // default return first tab - otherwise selected tab
- }
- }
- };
- j#( window ).on( "load", function(){
- getSelectedTab();
- }
- // get the selected tab and set the others unselected
- function getSelectedTab(){
- var tab = urlParameter( "selectedTab" );
- j$( "#" + tab ).attr( "aria-selected", true );
- j$( "[ class^='slds-tab' ]" ).each( function( index ){
- if( j$( this ).id !== tab ){
- j$( this ).attr( "aria-selected", false );
- }
- });
- }
- </script>
Add Comment
Please, Sign In to add comment