pre-JIRA5, we had some javascript inserted that would manipulate UI elements. This new quickCreate dialog is throwing a curve that i cant seem to figure out. When the dialog is initially loaded, things are ok, js gets executed and UI elements can be accessed.
but when the project or issuetype is changed and the dialog is re-displayed, I cannot figure out how to execute any js AFTER the dialog is re-displayed. I can detect when the form (project/issue type) changes but anything executed here is executed BEFORE the dialog is re-displayed for the new project/issue type. Any suggestions?
Community moderators have prevented the ability to post new answers.
you have to usebind event
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) { //your code here });
and check this
https://answers.atlassian.com/questions/47843/strange-javascript-problem-in-create-screen
this is correct answer @rambanam prasad
the reason why you cannot access the elements is because they are actually not present in DOM when the page loads and javascripts run. They are added to the DOM dynamically when the dialog actually appears.
So you must bind your js to NEW_CONTENT_ADDED event. It is fired whenever JIRA adds something to the DOM. In example when a Dialog is triggered.
as @rambanam prasad said, you have to wrap your js code inside new content added event.
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.
@Lance, if my answer helped then accept it as a anwer so we can close it
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
this works but the binding stays intact after the the create-dialog goes away. I tried to bind to an element that would only exist in the dialog, such as id=create-issue-dialog but that doesnt seem to work. Any suggestions?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
can you explian what's your requirement so i can help you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
AJS.$(function() { // execute on popup JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function(e, context, reason) { var $context = AJS.$(context); // for dialog only if(reason == JIRA.CONTENT_ADDED_REASON.dialogReady){ // get elements var submitButton = $context.find("#submit-button")[0]; var inputElement = $context.find("#input-element")[0]; inputElement.value = 'Hello World'; } }); })
try this.
use $context.find("#elementId")[0]; to get an element by id and $context.find(".elementClass"); to find all elements by class.
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.