在空间jQuery用户界面自动完成多个值 [英] jQuery UI autocomplete multiple values with spaces in

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

问题描述

我在这里使用jQuery用户界面自动完成多个值例如: http://jqueryui.com/autocomplete/#多

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

它的工作原理,如果你碰巧在你的价值观空白,除了罚款。然后,当您添加下一个值分隔被plonked成的中间值。

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.

任何想法如何,我可能prevent这一点。

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 " & ".

推荐答案

我创建了一个例子小提琴这里。它是基于在 JQuery用户界面的网页的示例

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(" & ");
}

这篇关于在空间jQuery用户界面自动完成多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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