Make a Multi Select list Behave like the Components Field!
This is a very handy solution that is easy to implement! If you have a Select List (multiple choices) that is populated with too many choices it can be a pain to search through them. By simply adding the following code to the description of your select list it will become an auto complete & drop down field:
Auto Complete / Drop Down
<script type="text/javascript">
(function($) {
AJS.$("#customfield_13785 option[value='-1']").remove(); //Removes the default value "None"
function convertMulti(id){
if (AJS.$('#'+id+"-textarea").length == 0){
new AJS.MultiSelect({
element: $("#"+id),
itemAttrDisplayed: "label",
errorMessage: AJS.params.multiselectComponentsError
});
}
}
AJS.toInit(function(){
convertMulti("customfield_13785");
})
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {
AJS.$("#customfield_<id> option[value='-1']").remove();
convertMulti("customfield_13785");
});
})(AJS.$);
</script>
Auto Complete / Drop Down
<script type="text/javascript">
(function($) {
AJS.$("#customfield_13785 option[value='-1']").remove(); //Removes the default value "None"
function convertMulti(id){
if (AJS.$('#'+id+"-textarea").length == 0){
new AJS.MultiSelect({
element: $("#"+id),
itemAttrDisplayed: "label",
errorMessage: AJS.params.multiselectComponentsError
});
}
}
AJS.toInit(function(){
convertMulti("customfield_13785");
})
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {
AJS.$("#customfield_<id> option[value='-1']").remove();
convertMulti("customfield_13785");
});
})(AJS.$);
</script>
Comments
Post a Comment