Dropdown remote API with user additions


#1

I’m having one hell of a time trying to get the dropdown to work with remote API content call, and allowing user additions, hoping someone can help me because i’m at the point now where frustration is setting in, and I know at that point I won’t really get anywhere productive :frowning:

The dropdown is being used to allow the visitor to search for users/email addresses or enter in a custom email address.

I don’t want them to be able to add a user addition unless it’s a valid email address. Everything works in regards to the remote API call/search, and adding those, but i’m having one hell of a time trying to validate the user addition, and even trying to use some jQuery hacks after the user selects the item, which all failed me miserably. Sounds simple, right? Well apparently not for me :frowning:

Here’s a jsFiddle of everything:
http://jsfiddle.net/tripflex/zewxp49s/

This example allows any user addition, and after spending hours trying to use different methods, I can’t figure out how to do a basic validation on the user addition and only allow if it’s a valid email.

On top of the gazillion other things I tried, docs on onAdd say “Is called after a dropdown selection is added using a multiple select dropdown, only receives the added value” … but yet it doesn’t appear that way, if you view console you see that onLabelCreate is called after onAdd … wtf??

Reason being, I tried to remove the dropdown after being added while in the onAdd callback, but that clearly doesn’t work, like everything else I tried…

AHHHH please someone help me figure this out!