Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to load my javascript on Greenhopper New Card page

Bharadwaj Jannu
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.
April 6, 2014

hi,

I wrote some javascript as follow

(function($) {
    /*AJS.toInit(function(){
        // old function
		alert("init");
    });
	*/
   
    JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {
        //alert("bind");
		
		var tex1=AJS.$("#newField_customfield_12051");
		alert(tex1);
		var tex2 =  AJS.$("#customfield_12051");
		alert(tex2);
		if(tex1 == null){
			alert("Inside 1");
		}
		else {
			alert("In 2");
		}
		var t1 = AJS.$("#customfield_12051-field").length;
		alert (t1);
		
		
	});
})(AJS.$);

none of the alert windows appeared when I click on New Card button in Greenhopper board.

I loaded script as web-resource module and placed as

<web-resource key="hide_nda_programs" name="HideNDAPrograms">
        <dependency>jira.webresources:global-static</dependency>
        <resource type="download" name="HideNDAPrograms.js" location="/js/HideNDAPrograms.js"/>
		<context>atl.general</context>
		<context>atl.popup</context>
	</web-resource>

Am I right in case of JIRA.bind etc., even in Greenhopper scenario

1 answer

1 vote
Fabio Racobaldo _Herzum_
Community Champion
April 8, 2014

Hi Bharadwaj,

I had the same problem. After some investigation, I figured out the issue. My Javascript took place while page is loading.

I fixed this problem just adding a timeout as follow :

jQuery(document).ready(function() {
	setTimeout(myfunction,3000);
	
});

function myfunction(){
 //HERE YOUR CODE
}

Hope this helps.

Fabio

Fabio Racobaldo _Herzum_
Community Champion
April 10, 2014

Any news? Did the suggested approach resolve your issue?

Let me know and , if yes, accept my answer.

Regards,

Fabio

Suggest an answer

Log in or Sign up to answer