如何使用jQuery自动完成多个单词 [英] How do i use JQuery Autocomplete for multiple words

查看:127
本文介绍了如何使用jQuery自动完成多个单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自动完成字段,只是想知道我怎么可以用它
多个单词?当我输入第一个字它的作品完美,但
当在第二个字我空间和类型,其两个单词发送回
到服务器,当然结果是错误!

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,

爪哇JavaScript

'Java javascript'

第一个字'Java的,自动完成效果很好,拉列表中。

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

但是当我的空间和JavaScript的类型,自动完成发送的Java
+ JavaScript的我的AJAX功能。

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

任何想法如何解决这一问题?

Any ideas how to fix this?

推荐答案

看起来你不是,内置的实现不支持它 - 你可以在上面的链接看到:是不是稳定版本的一部分或发行。

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}

更新

jQueryUI的现在已经更新了最新的版本,使得这个答案已经过时了。一个例子UPTODATE可以在这里找到。

JQueryUI has now been updated for the newest versions making this answer obsolete. An uptodate example can be found here

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

这篇关于如何使用jQuery自动完成多个单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆