I have one select2 element which has ajax data source.
In my program I happen to set the value of one select2 element 2 times programmatically.
I have a JSBin which shows the code I have used in my scenario.
In my JSBin above, I set the value of one select2 element twice programmatically, but the option that is shown visually selected is the last option I set programmatically.But upon inspecting the source, you will realise the html select element has two option with value selected.
In my real program, two option of the select html element has the value of selected, but the one that is shown visually as the selected one is not the last one I set programmatically
This picture is when I view source of my real program.
.
In my real program, the option with value CA60010 is set first, then later after that the option value with SA60100 value is set next. However, visually on the screen, the one that is shown to be selected is ‘CA60010’.
Am I using the wrong technique to make one option selected? Do I have to use another method, such that at any one time only one option is selected?