Validating option selection before adding to dropdown selected


Hi!, i am trying to validate the option selection through ajax to see if the selected value is available but am unable to remove the selected value programatically. The onAdd callback seems tu return before the value array refresh and does not let the user break before the actual add.

the validation can be done inline and doesnt need to be ajax. The algorithm is pretty straightforward, but since im dealing with a large amount of data, i cant dynamically remove options from all the dropdown in the page at the same time without causing refresh lag

since the callback does not let me return before adding the option to the selected values, i tried removing the last added option through .dropdown(‘remove selected’, value) but the function seems to be called before the value is added to the actual selection divs.

am i missing something or maybe im not doing it the right way?

Let me know if it is not clear enough. im not fluent in english and am trying to make as much sense as i can. thank you.

ie: $a.dropdown({
//check if value can be added, through ajax
//rollback or remove option from selected.