Javascript does not reload on JIRA 5

Hi,

I have a javascript to pre-populate value for my custom field based on user log in, it works perfectly fine until the user change the project which has different context of the field. For example, user log in is in "inhouse" group, "Client" custom field (select list) change to "inhouse" value, then if user select another project which has the same context, the value is still the same. However, if user select another project which has different context (different select list value), the "Client" field is reset and my script does not reload again. Please advise how can I reload the script whenever user select different project? window.onload doesn't work from my understanding.

Thanks,

2 answers

1 accepted

Accepted Answer
0 votes

For dinamically loaded elements you can use jQuery.on function or jQuery LiveQuery plugin that depends of your purposes

Can I have some sample please? e.g. execute the function if one of the field is clicked

jQuery(document).on('click', 'your field selector', handlerFunction).

Plenty more you can find in this blog : http://api.jquery.com/on/

hey, it looks than more clean way use this function :

JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {

...

});

Try it, this one resolve many problems with dynamic reloading.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

26,425 views 2 7
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