Hi,
I know a lot of people have asked in the past about multi-select field behaving like components/versions, but is it possible to get a single-select to behave like that as well?
When i try to edit the code, i have problems with it sticking or it will create duplicate fields
Multi-select solutions can be found:
CK1's post:
<script
type
=
"text/javascript"
>
(
function
($) {
//
"customfield_10400"
is the number of the custom
//
multiselect field you want to change as e.g.
//
seen at the end of the
"configure"
page url of
//
the field you want to change this way
AJS.$(
"#customfield_10400 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_10400"
);
})
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED,
function
(e, context) {
AJS.$(
"#customfield_10400 option[value='-1']"
).remove();
convertMulti(
"customfield_10400"
);
});
})(AJS.$);
<
/script
>
After the adding the above script, the width of the single select custom field decreased. Is there a way to increase the width of the single select custom field ?
Actually the code on
https://answers.atlassian.com/questions/43534
worked fine for my single-select list to behave like component/version (multiple choices possible).
If you have a single-select list and want it to behave like Priority (single choice) you can use AJS.SingleSelect instead of AJS.MultiSelect. Like:
<script type="text/javascript">
(
function
($){
new
AJS.SingleSelect({
element: $(
"#customfield_10052"
),
itemAttrDisplayed:
"label"
,
errorMessage: AJS.params.multiselectComponentsError
});
})(AJS.$);
</script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You try this case: Multi-Select > Single-Select
<script type="text/javascript">
(function($) {
AJS.$("#customfield_10159 option[value='-1']").remove();
function convertMulti(id){
if (AJS.$('#'+id+"-field").length == 0){
new AJS.SingleSelect({
element: $("#"+id),
itemAttrDisplayed: "label",
errorMessage: AJS.params.multiselectComponentsError
});
}
}
AJS.toInit(function(){
convertMulti("customfield_10159");
})
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {
AJS.$("#customfield_10159 option[value='-1']").remove();
convertMulti("customfield_10159");
});
})(AJS.$);
</script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have options in the select drop down list which start with the following (which for whatever seems to limit my ability to search using this code). Tried it out on another drop down list and it worked perfectly. Any ideas?
A.1.a - Commercial
A.1.b - UW
A.1.c - PEAK
A.2.a - Test
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.