Create a Back Button in Jira

Daniel_90 August 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é August 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
Daniel_90 August 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é August 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 August 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é August 17, 2015

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

0 votes
michael_ngangom
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.
August 14, 2015
This is the general idea:
<button onclick="goBack()">Back</button>

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

 

Hope this helps!

 

Suggest an answer

Log in or Sign up to answer