0

I have created a tab-pane using HAML as shown in my code snippet below (2 tabs)

//tabs
tab-content
  .muses.active.tab-pane
    .muse_header
      %h3
    %ul.muses
    .center
      %button.btn#get_more_answers.hide Fetching Content
  .questions.tab-pane
    .question_header
      %h3
    %ul.questions

enter image description here

As shown above I have 2 tabs (.muses.active.tab-pane and questions.tab-pane)

Now I need to specify certain actions depending on which tab is active. How can I write the if statement to determine which tab-pane is active at one point of time?

Josh Crozier
  • 233,099
  • 56
  • 391
  • 304
Zhen
  • 12,361
  • 38
  • 122
  • 199
  • Posible answer here (http://stackoverflow.com/questions/300078/jquery-ui-tabs-get-currently-selected-tab-index) – aki Feb 02 '12 at 11:29

1 Answers1

1

If you are using jQuery framework, you can find the active tab using following command, $('.active.tab-pane')

You can check if the active tab is a muse or question by checking against the class of that tab as follows,

if($('.active.tab-pane').hasClass('muses')){
  alert("its muses tab");
} else if($('.active.tab-pane').hasClass('questions')){
  alert("its questions tab");
}
nkm
  • 5,844
  • 2
  • 24
  • 38