It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

JIRA issue screen tab pane tab change event

JIRA.ViewIssueTabs.onTabReady(function () { 
  console.log("Questions Tab JS loaded!");
});

Above event is getting called for all tabs.

Is there any way to detect (event) issue screen tab change event using JavaScript?

1 answer

1 accepted

3 votes
Answer accepted
Nir Haimov Community Leader Aug 22, 2018

Hi @nija kanthan

I don't understand.

The code you sent is in JavaScript, 

JIRA.ViewIssueTabs.onTabReady

 Is the event, the function inside doing what ever you want when the event occur, which means you detect it, catch and do what you want there...

So i don't understand your question.

Screen Shot 2018-08-23 at 11.39.23 AM.pngI have custom tab called Questions. I want an event to detect tab change. If the selected tab is Questions i want to call some JavaScript function. Above method is getting called for all tabs.

OK,

You still have to call 

JIRA.ViewIssueTabs.onTabReady

But inside do what you want only if you are in tab  Questions.

JIRA.ViewIssueTabs.onTabReady(function () { 
if ($("#issue-tabs").find(".active strong").text() == "Questions") {
write your code here
}
});
Like # people like this

It works,

if($("#issue-tabs").find('.active a').text() == 'Questions') {
//code goes here
}

I changed the condition into this.

Thanks for the reply :) 

Nir Haimov Community Leader Aug 23, 2018

You are welcome :)

The accepted answer is working perfectly until you need i18n in your plugin. In that case I prefer the following solution:

$("li.menu-item.active-tab")[0].getAttribute("data-key")

this will give back the "plugin key:module key". It is independent of the selected language and hopefully unique.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

308 views 1 3
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you