Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to add a new option to single select programmatically?

Jose Luis May 3, 2016

I don't seem to be able to find how to do this anywhere, I've tried adding a new aui-option to the datalist but even though the new option does appear on the list it won't be there when you search for it by writing on the input field.

Is there some way to do this?

2 answers

1 accepted

0 votes
Answer accepted
Sean Curtis
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 4, 2016

There's no way to add a new option programatically (yet). You could use the async version and back it with a rest resource which could provide more results.

Alternatively you can add the "can-create-values" attribute to the element, and then set it's value to something. It will appear as a special option in the list with "(new value)" after it.

http://jsbin.com/gogoyo/edit?html,js,output

Jose Luis May 4, 2016

Those options don't quite work for what we want but thanks anyway.

0 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 4, 2016

I may be misunderstanding the question here, but a single-select list's options are determined by data in the database.  Aui has nothing to do with that, it's for the front-end.  They're not related to each other.

Jose Luis May 4, 2016

I'll try to explain here, I'm following the first example in (https://docs.atlassian.com/aui/latest/docs/single-select.html), the synchronous one. When I write the options on the template like that it works fine, but I want to be able to add or remove options afterwards since they should change depending on what the user chooses on another field.

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 4, 2016

Ah, ok, so you already have the list from the database and you just want to remove (or re-add) existing options.  I'm afraid I don't know javascript well enough to help you there.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events