Javascript does not reload on JIRA 5

tpham August 21, 2012

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

0 votes
Answer accepted
Igor Loskutov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2012

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

tpham August 22, 2012

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

Igor Loskutov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2012

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

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

0 votes
Igor Loskutov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2012

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