Missed Team ’24? Catch up on announcements here.

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

Creating a custom field of type select2

Cynthia Fehr
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.
June 4, 2015

I want to create a custom field that renders the same way as components and versions.  I believe that drop-down is of type select2.

Is there a way I can do that?  Are there any examples?

Thank-you

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Cynthia Fehr
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.
June 11, 2015

Thanks for the help.  I am putting what I ended up with in case it helps others.  Also suggestions to improve would be great as I am not a javascript expert.

 

This is pasted into the announcement banner.

<script type="text/javascript">
(function($){
$(document).ready(function(){
function convertField(id) {

if (id.length===1){

new AJS.MultiSelect({

element: id,

itemAttrDisplayed: "label",

errorMessage: AJS.params.multiselectComponentsError

});

}

}

AJS.toInit(function() {
console.log("DEBUG: Init Event");
var main_window=AJS.$("#issue-create select[name=customfield_11711]")
convertField(main_window);


});
JIRA.bind(JIRA.CONTENT_ADDED_REASON.inlineEditStarted, function (e, context,reason) {
console.log("DEBUG: inline editing");
var main_window=AJS.$(".inline-edit-fields select[name=customfield_11711]")
convertField(main_window);
});
$(document).bind('dialogContentReady', function(event, dialog) {
console.log("DEBUG: Pop-up window created");
var pop_up_window=AJS.$(".jira-dialog select[name=customfield_11711]")
convertField(pop_up_window);
});
});
})(AJS.$);
</script>

0 votes
Cynthia Fehr
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.
June 7, 2015

Thanks for the reply.  Does this solution allow you to type in values you want to add to the database for the custom field just like if you are adding to a new component?

0 votes
JamieA
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.
June 4, 2015

I thnk there are a couple of plugins that add these, but it's also pretty simple to do it with javascript: https://answers.atlassian.com/questions/43534

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events