Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,300,961
Community Members
 
Community Events
165
Community Groups

Customfield with select2 closes while editing

Edited

Hi!

I'm working with new customfield type where options go from ajax.

My code:

#disable_html_escaping()
#customControlHeader ($action $customField.id $customField.name $fieldLayoutItem.required $displayParameters $auiparams)

#set ($field_uid = $customField.id)

<input class="issue-link-field single long-field" id="${field_uid}" name="${field_uid}"/>

<script>

AJS.$("#${field_uid}").auiSelect2({
ajax: {
url: function (params) {
return '/rest/croc-service-import/1.0/configuration-unit/search?str=' + params;
},
results: function (data, page) {
var confunits = [];
jQuery.each(data, function (index, value) {
var id = value["key"];
var text = value["name"];
confunits.push({id: id, text: text});
});
return {
results: confunits
};
}
}
});
AJS.$("#${field_uid}").select2('data', {id: "$key", text: "$name"});


</script>
#customControlFooter ($action $customField.id $fieldLayoutItem.fieldDescription $displayParameters $auiparams)

The problem is that if I click edit in issue, the editing closes at the moment select2 opens.  So I cannot save anything. Screens of this attached. Are there any ideas what can I do with it?screen.PNGscreen1.PNG

 

2 answers

Did you ever find a solution? 

I have implemented a custom field type using select2, and on quick edit, it only closes on a specific project but not another. 

Hi,

I new here. May I ask, why are you using <input> instead of <select> ?

Hi!

Because I can't use select for ajax statements. As said in official select2 doc - use imput tag for ajax.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Software

An update on Jira Software customer feedback – June 2022

Hello Atlassian Community! Feedback from customers like you has helped us shape and improve Jira Software. As Head of Product, Jira Software, I wanted to take this opportunity to share an update on...

182 views 2 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you