Twitter Bootstrap Tabs: Go to Specific Tab on Page Reload or Hyperlink

前端 未结 24 1451
夕颜
夕颜 2020-11-22 04:57

I\'m developing a web page in which I\'m using Twitter\'s Bootstrap Framework and their Bootstrap Tabs JS. It works great except for a few minor issues, one of which is I do

24条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 05:23

    While the JavaScript solution provided may work, I went a slightly different way that requires no additional JavaScript, but does require logic in your view. You create a link with a standard URL parameter, like:

    My Link
    

    Then you simply detect the value of activeTab to write 'class="active"' in the appropriate

  • Pseudocode (implement accordingly in your language). Note I've set 'home' tab as a default active if no parameter provided in this example.

    $activetabhome = (params.activeTab is null or params.activeTab == 'home') ? 'class="active"' : '';
    $activetabprofile = (params.activeTab == 'profile') ? 'class="active"' : '';
    
    
  • Home
  • Profile
提交回复
热议问题