Community Announcements have moved! To stay up to date, please join the new Community Announcements group today. Learn more
×Hello Community,
This is my plugin application description:
I have a web-item button,I need to click the button to trigger the REST I wrote myself and refresh the current page.
So I refer to JavaScript to listen for the button.Here is my code snippet:
atlassian-plugin.xml:
<web-item key='top-nav-bar-sign-in' name='top-nav-bar-sign-in' section='system.top.navigation.bar' weight='18'>
<label key="sign.in.top.navigation.bar.title"/>
<condition class="cn.com.nd.jira.condition.SignInCondition"/>
<link linkId="top-nav-bar-sign-in-link"/>
</web-item>
js:
require(['jquery'], function ($) {
$('#top-nav-bar-sign-in-link').on('click', function () {
$.ajax({
type: "GET",
url: "/rest/signIn/1.0/sign/in",
contentType: "application/json"
}).done(function () {
return false;
// window.location.reload();
});
});
});
Js always runs, but sometimes the click event does not execute,This rather confuses me.
The final solution is,Bind the click event after the page has loaded.
$(function () {
$('#linkId').on('click', function (event) {
// do something
}
}
When I click my custom button, my JS is not triggered: the page is refreshed first, I guess, the page is refreshed first, so my JS is invalid
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Unlock your potential and learn how to use Jira Product Discovery to your advantage. You’ll have the expertise to revolutionize ideas and insights, roadmapping, engage and align teams and stakeholders, and deliver the best solutions—faster. Enroll today!
Start Learning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.