autocomplete a sentence via jQuery autocomplete

1,445 views
Skip to first unread message

Will Kriski

unread,
Aug 24, 2012, 10:00:20 AM8/24/12
to ang...@googlegroups.com
I'm trying to set up autocomplete for a sentence (multiple words). Here's the jsfiddle which is partially working. http://jsfiddle.net/willkriski/F27ZK/

I'd like the down arrow and tab (to select words) to work, then add a space as it does now after selecting a word, but to allow for multiple words. Right now it doesn't work for more than one word. I tried adjusting the jquery example but I'm a little lost with directives :)
Also if I could add words to the array if one isn't found (to build up a vocabulary of used words), triggered on the space bar that would be great too. Or possibly click an 'Add word' entry in the list to manually add the current word.

Thanks,
Will

Getulio Romão Campos Junior

unread,
Aug 24, 2012, 4:26:01 PM8/24/12
to ang...@googlegroups.com
Have you take a look at Select2 ???




--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en.
 
 

Will Kriski

unread,
Aug 24, 2012, 4:49:53 PM8/24/12
to ang...@googlegroups.com
Haven't heard of that. Plus it's always a tough task for me to try to convert this into a directive ;)

W

Pawel Kozlowski

unread,
Aug 24, 2012, 4:52:58 PM8/24/12
to ang...@googlegroups.com
Hi Will,

On Fri, Aug 24, 2012 at 10:49 PM, Will Kriski <wkri...@gmail.com> wrote:
> Haven't heard of that. Plus it's always a tough task for me to try to
> convert this into a directive ;)

The good news is that it was already converted:
http://angular-ui.github.com/ :-)

Cheers,
Pawel

Will Kriski

unread,
Aug 24, 2012, 4:56:56 PM8/24/12
to ang...@googlegroups.com
Yeah I just found that, thanks. Let's see if it can build sentences using the start of each letter (not any letter), and add new words to the list :)

W

Roy Choo

unread,
Aug 24, 2012, 10:27:22 PM8/24/12
to ang...@googlegroups.com
hmmm, I think i created this fiddle and i was asking if this is included in angular-ui.
Hi Pawel, i tried looking at angular-ui but i couldn't find it :(

Could direct me ?

Regards
Roy

Roy Choo

unread,
Aug 24, 2012, 11:00:46 PM8/24/12
to ang...@googlegroups.com
Hi Will,

Anyway i jus completed my fiddle and it supports autocomplete as a sentence.


Regards
Roy

Will Kriski

unread,
Aug 25, 2012, 9:42:46 AM8/25/12
to ang...@googlegroups.com
Thanks Roy this is looking good. When I type an f I get 3 words side by side Actionscript BASIC Coldfusion and a second similar row.
Also how can I make it trigger on the start of the words, not any letters in the word itself, ie starts with f?

Will

Roy Choo

unread,
Aug 26, 2012, 9:48:52 PM8/26/12
to ang...@googlegroups.com
Hi,

How about this?
http://jsfiddle.net/roychoo/C5p6B/1/

Regards
Roy

Roy Choo

unread,
Aug 26, 2012, 9:52:20 PM8/26/12
to ang...@googlegroups.com
Hi,

by the way, i took the code from here.

http://stackoverflow.com/questions/2382497/jquery-autocomplete-plug-in-search-configuration

One thing i add is to control the number of words appearing in the selection. The previous example will keep on adding the word and if you delete the input and type again, depending, it will have a number of words appearing in the selection.

Regards
Roy

Will Kriski

unread,
Aug 27, 2012, 8:47:56 AM8/27/12
to ang...@googlegroups.com
This is looking great thanks. I'd like the selections below the text input to only show the current word options (ie availableTags list) not the previous choices concatenated. Basically people who can't speak will be able to type a sentence quickly by having autosuggestions. I also hope to store new words in a list after they hit the space bar. Maybe I can figure out how this works :)

Will
Reply all
Reply to author
Forward
0 new messages