Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

call JavaScript from web item link doesn't work sometimes?

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:


<web-item key='top-nav-bar-sign-in' name='top-nav-bar-sign-in' section='' weight='18'>
<label key=""/>
<condition class=""/>
<link linkId="top-nav-bar-sign-in-link"/>


require(['jquery'], function ($) {

$('#top-nav-bar-sign-in-link').on('click', function () {
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.



2 answers

1 accepted

0 votes
Answer accepted

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  

Suggest an answer

Log in or Sign up to answer

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