Customfield with select2 closes while editing

Yury Shashkin September 2, 2020

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

0 votes
KC Wong June 5, 2022

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. 

0 votes
Attila Czegledi September 3, 2020

Hi,

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

Yury Shashkin September 4, 2020

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