views:

3803

answers:

4

I have an autocomplete field and am just wondering how can i use it for multiple words? When i type the first word it works perfect, but when i space and type in the second word, its sends the two words back to the server and of course the results are wrong!

eg. when i type the two words,

'Java javascript'

the first word 'Java', autocomplete works well, pull the list.

but when i space and type javascript, autocomplete sends 'Java +javascript' to my ajax function.

Any ideas how to fix this?

A: 

try this:

http://docs.jquery.com/UI/Autocomplete

Ramesh Soni
+4  A: 

Looks like you can't, the built in implementation doesn't support it - you can see in the link above: "is not part of the stable release or distribution".

However, I've downloaded and use the external version, available here:

http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/

it's a little bigger, but the usage is exactly the same, you don't have to change anything, for multiple selection, add to the options {multiple:true}

Liorsion
+1  A: 
$("#tagnames").autocomplete("/tags/filter", {
        max: 6,
        highlightItem: true,
        multiple: true,
        multipleSeparator: " ", 
  })

To enable auto complete for multiple words you should set options multiple : true and multipleSeparator: " "

Rama Vadakattu
+3  A: 

If you are using the "bassistance" version of Autocomplete, it's built in. But if you are using the jQuery UI version, there is an example here:

http://jqueryui.com/demos/autocomplete/#multiple

Sam