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
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.
Cheers,
Christophe
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There are thousands of ways to insert a button in the DOM Depends on your plugin implementation....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is the general idea:
<button onclick="goBack()">Back</button>
<script>
function goBack() {
window.history.back();
}
</script>
Hope this helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.