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

Create a Back Button in Jira

Daniel_90 Aug 14, 2015

Hi there,

I created a button (AUI button) in our JIRA plugin. Here is the HTML snippet:

<button  id="help-back-button" class="aui-button">Back</button>

 Now I want to give this button the behavior to execute the "back operation". I want to step one webpage back (namely going back to the JIRA Dashboard). I tried some Javascript code, referencing with the button's ID. However, nothing happened...could you tell me how to resolve this?

 

Thanks a lot in advance,

Daniel

3 answers

1 vote
Christophe Promé Aug 14, 2015

Something like this should do the trick :

<button onClick="history.back()">click me</button>

If you don't want to write javascript directly in your HTML, you can also attach a listener and call the history.back() function from your javascript callback.

More about the history api.

 

Cheers,

Christophe

0 votes
This is the general idea:
<button onclick="goBack()">Back</button>

<script>
function goBack() {
    window.history.back();
}
</script>

 

Hope this helps!

 

0 votes
Daniel_90 Aug 14, 2015

Hi Christophe, thanks for answering.

 

I tried to solve it with javascript callback according to the history api. Here is the code

AJS.$(
"#help-back-button").click(function() {
	history.back(); 
});

 Unfortunately, nothing happens. So I have two questions:  1) Is this code wrong? 2) When I have Javascript code updated, does JIRA suddenly realize this or am I obliged to use fastdev or the command atlas-run again in order to make the changes applicable?

 

Thanks for answering,

Daniel

Christophe Promé Aug 16, 2015

The code looks fine. Is your button attached to the DOM when you create the listener ? Do you have any error in the console ? Add a 'debugger' statement in your code and try step by step debugging within your browser. Usually, it is enough to reload the page to get the newest javascript.

Daniel_90 Aug 17, 2015

Thanks Christophe for answering. The button is not attached to the DOM, didn't know this is required. What is the code I have to insert in the DOM? In the console I don't have errors. There is just nothing happening when clicking the button. Well, the only thing what's happening is a refresh of the current page. However, with the button I'd like to go one page back. Thanks for your help conserning the POM code. Daniel

Christophe Promé Aug 17, 2015

There are thousands of ways to insert a button in the DOM Depends on your plugin implementation....

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Jira

Try Jira Cloud for Outlook: Organize your work without leaving your inbox

Hi Atlassian community, My name is Max and I work on the product integration team at Atlassian. I am pleased to announce the early access program for the Jira Cloud add-in for Outlook. This add-in...

834 views 0 12
Read article

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