I am displaying a velocity templte as a popup using the "<styleClass>trigger-dialog</styleClass>". The template is served through a servlet and it is invoked against a menu item. Now, how do I execute javascript when the popup loads?
AJS.$(document).ready(function() {} is always executing and I can not use it manipulate html elements of the popup page. Any hits would be really helpful.
Community moderators have prevented the ability to post new answers.
Have you tried using
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) { // more Javascript });
instead of
AJS.$(document).ready(function() { // more Javascript });
?
As you have seen, the jQuery ready only fires when the page is first loaded, not when popups are loaded. The JIRA.bind
on JIRA.Events.NEW_CONTENT_ADDED
will fire when popups get loaded.
Unfortunately, the only documentation I could find on this is https://developer.atlassian.com/display/JIRADEV/Custom+Fields+that+use+CSS+or+JavaScript+Web+Resources+in+JIRA+5.0 , and it’s not much.
Ah, well I knew it had to be there somewhere. I can’t say that I fully understand why it had to be in the ready handler, but the important thing is that it works for you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just having the following code did not work,
AJS.$(document).bind('dialogContentReady', function(event, dialog) { }
It had to be put inside onready handler
AJS.$(document).ready(function() { AJS.$(document).bind('dialogContentReady', function(event, dialog) { } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i think if you change project or issue type it won't help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was able to use the JIRA.bind
on JIRA.Events.NEW_CONTENT_ADDED
technique to run Javascript when the project and/or issue type was changed. In my case, I did have to make sure that the Javascript was present before the user hit the “Create Issue” button, which basically meant including that code on every page. But it did work. And if you don’t need the popup to appear on the “Create Issue” screen, you won’t have to worry about the project and/or issue type changing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
if you don’t need the popup to appear on the “Create Issue” screen then the above scripts well
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i think if you change project or issue type it won't help.
I have the same problem. Is there any other solution than including JS in every page? We have very very much Javascripts...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.