Skip to content

Instantly share code, notes, and snippets.

@ifourmanov
Created December 10, 2013 09:28
Show Gist options
  • Save ifourmanov/7887972 to your computer and use it in GitHub Desktop.
Save ifourmanov/7887972 to your computer and use it in GitHub Desktop.
To render multiselect fields with fancy component like rendered in jira, add following js to description field. Replace <id> with custom field ID
<script type="text/javascript">
(function($) {
AJS.$("#customfield_<id> 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_<id>");
})
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {
AJS.$("#customfield_<id> option[value='-1']").remove();
convertMulti("customfield_<id>");
});
})(AJS.$);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment