Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Web fragment loses action listener after issue update

Brian Ho June 17, 2021

I have a webitem displayed on my issues that will generate a username and password. It's hooked up to a web resource like so:image.png

js/user-cred-gen.js:

AJS.$(document).ready(function () {

function genUserCred() {
var issue = JIRA.Issue.getIssueKey();
let url = `/rest/cb-automation/latest/hooks/e6f8904f78fbf84cbb52ce913b553553968b2b31?issue=${issue}`;

$.post({url: `${url}`, headers: { 'Content-Type' : 'application/json'}}, function(result){
console.log("Ran successfully");

JIRA.trigger(JIRA.Events.REFRESH_ISSUE_PAGE, [JIRA.Issue.getIssueId()]);
});
};

function pollDOM(){
const el = AJS.$('#user-cred-gen');
console.log("Polling DOM for #user-cred-gen");
if (el.length > 0) {
AJS.$('#user-cred-gen').click(function(e) {
genUserCred();
});
}
else {
setTimeout(pollDOM, 300);
}
}
pollDOM();
});

When refreshing the page, the button works fine. However, if I edit a field on the customfield pane from the View Issue screen, the button no longer works.

 

1 answer

0 votes
Brian Ho June 17, 2021

this is how I'm editing the issue in the customfield pane: image.png

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events