Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to work with 'tabSelect' event.

Mark H_ Williams April 28, 2016

The AUI documentation for the Tabs control says that the AUI Tabs has only one event 'tabSelect'. How can I use this to tell which tab is selected and act on that select tab? Is there any documentation for this? 

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Answer accepted
Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 28, 2016

Hi Mark,

I do it like:

html:
<ul class="tabs-menu">
  <li class="menu-item active-tab"><a href="#calendar-tab"><strong>Calendar</strong></a></li>
  <li class="menu-item"><a href="#time-tab"><strong>Timesheets</strong></a></li>
</ul>
 
JS:
AJS.$("#tabs > ul > li > a").bind("tabSelect", function(e, o) {
  if (o.tab.attr("href") == "#time-tab") {
  } else {
  }
}
Mark H_ Williams April 29, 2016

Both answers work but this one is simpler and works with the actual object that's being returned. 

Thank you

2 votes
Sean Curtis
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 28, 2016

You can get the tab (the link) they clicked via the event.target. Then you can look up the corresponding tab pane by looking at the href of that event.target. Open http://output.jsbin.com/xenika/ and look at your browser console log when you change tabs.

AJS.$('#my-tabs').on('tabSelect', function(e) {
  console.log('The tab clicked is:', e.target);
  console.log('The corresponding tab pane is:', AJS.$(e.target.getAttribute('href'))[0]);
});
TAGS
AUG Leaders

Atlassian Community Events