Create a Back Button in Jira

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

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

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

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

 

Hope this helps!

 

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

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.

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

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
Community showcase
Posted Sep 25, 2018 in Jira

Atlassian Research Workshop opportunity on Sep. 28th in Austin, TX

We're looking for participants for a workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sha...

465 views 7 5
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you