0

I'm using jQuery UI autocomplete multiple values example here: http://jqueryui.com/autocomplete/#multiple

It works fine except if you happen to have whitespace in your values. Then the separator gets plonked into the middle of the value when you add the next value.

Any idea how I might prevent this.

I basically have lots of values in my source array that are sentences, and I want to be able to add them via autocomplete and have them separated by " & ".

1 Answer 1

2

I created an example fiddle here. It is based on the example on the JQuery UI pages.

The source contains some sentences:

['This is some sentence', 'While this is another one', 'Just filling up some space']

splits on &...

this.value = terms.join( " & " );

.... and (this might have been your problem) has an updated version of the split function in the example:

function split( val ) {
    return val.split(" & ");
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks so much for that. That is prefect!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.