Missed Team ’24? Catch up on announcements here.

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

Javascript in Custom Fields not firing on Create Issue screen

Alex D. August 24, 2012

Hi everyone,

In JIRA 5.x we are hoping to run some custom JavaScript whenever the create issue or edit issue popup overlays are displayed... as well as when the content is reloaded from an AJAX request (e.g. a dropdown selection changes causing a reload)

We've tried code samples that trigger based on checking the window.location.href but these won't work as the parent page is the Dashboard or something else.

There was also some JIRA based jQuery events that we thought we could listen for but none seem to work.

Is there a specific JIRA Event that is fired when the create issue/edit issue overlays are loaded/re-loaded (via AJAX)?

For example this one doesn't seem to work;

AJS.$(document).bind('dialogContentReady', function(event, dialog) {...});

nor does this one

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

Any suggestions? We had custom JavaScript working in version 4.3.4 but have not been able to get it to work in 5.x with the changes to the create/edit issue pages now rendering as overlays.

Any help is much appreciated! Thanks!

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
RambanamP
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 27, 2012
0 votes
Harry Chan
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 24, 2012

You need to call the function once when the document is ready and when the NEW_CONTENT_ADDED event is fired.

Refer to https://answers.atlassian.com/questions/79201/jira-5-1-2-questions-re-pop-up-issue-edit-window for more information.

Alex D. August 27, 2012

Hi,

Thanks for the reply. I tried the following simple code:


<script>

(function($) {

alert('on ready');

AJS.toInit(function(){

alert('in init');

});

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

alert('content added');

});

})(AJS.$);

</script>

After the code is added to the description box of the custom field, I click the update button and it redirects me back to the list of all custom fields and then the popup alert is displayed.

I also tried the code below, and all of hte combinations, but either I did not get an alert popup or the alert popped up on the list of custom fields page, but still not the "create issue" page.

AJS.$(document){

alert('on ready');

});

AJS.toInit(function(){

alert('in init');

});

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

alert('content added');

});

Any suggestions?

Harry Chan
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 27, 2012

It might have to do with page load ordering. I put all my stuff in the description of summary and that worked.

TAGS
AUG Leaders

Atlassian Community Events