You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
Hello!
We had a question in Moscow Atlassian User Group. Here is the question:
This code does not work in Atlassian Jira 8.8.1
<script type="text/javascript">
var customfield_11123 = AJS.$("#customfield_11123").aui-select2();
console.log(AJS.format("{0}", customfield_11123.aui-select2()));
$('div#id_customfield_11123').css("width","100%")
</script>
How to make it work?
First let's describe what the code does. Suppose, we have a select custom field:
And we want to make it look like this:
We converted a usual Jira select custom field into Select2 custom field.
The script in the question was added to the description of the my_select_list field. It is good to see that Jira 8.8.1 does not let put JavaScript code into the description field. The correct way would be to create an app to do changes to UI, but we want to make these changes without an app.
I do not recommend to use this solution but here is the answer.
Add the following JavaScript code to the announcement banner:
<script type="text/javascript">
(function ($) {
AJS.toInit(function () {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context, reason) {
if (reason == JIRA.CONTENT_ADDED_REASON.dialogReady) {
if ($('#create-issue-dialog').length || $('#edit-issue-dialog').length) {
var customfield_10008 = $("#customfield_10008").auiSelect2();
console.log(AJS.format("{0}", customfield_10008.auiSelect2()));
$('div#s2id_customfield_10008').css("width","100%");
}
}
});
});
})(AJS.$);
</script>
customfield_10008 is the id of the my_select_list custom field.
This code will work for the create and edit issue dialog.
Alexey Matveev _cPrime_
Community LeaderSoftware Developer
cPrime
Moscow
1,557 accepted answers
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
5 comments