jQuery Select2标记模糊 [英] jQuery Select2 Tag on Blur
问题描述
我正在使用Select2在我的应用程序中创建Gmail样式的电子邮件地址字段.除一种情况外,它的效果很好:当用户键入电子邮件地址,并且不在其后放置空格或逗号,并且不按Enter或Tab键时.例如,如果他们只是键入电子邮件地址,然后使用鼠标选择表单中的下一个字段,那么他们键入的电子邮件地址就会消失.
I'm using Select2 to create a Gmail-style e-mail addresses field in my application. It works great except for one case: when the user types in an e-mail address and doesn't put a space or comma after it, and doesn't hit enter or tab. For example, if they just type an e-mail address and then use the mouse to select the next field in the form, the e-mail address they typed goes away.
我有一个示例jsfiddle 此处可以说明问题.
I have an example jsfiddle here that illustrates the problem.
这是我在隐藏的输入上设置select2的方式:
Here's how I'm setting up select2 on my hidden input:
$(function(){
$('input').select2({
tags: [],
width: "300px",
dropdownCss: {display: 'none'},
tokenSeparators: [',', ', ', ' ']
});
});
我是否可以设置select2,以便onBlur只需剩下剩下的东西,当前就不是标签并将其变成一个标签?
Is there a way for me to set up select2 so that onBlur it just takes whatever is left and is not currently a tag and makes it one?
推荐答案
select2库的3.3版现在使用"selectOnBlur"选项支持此功能.
This is now supported in version 3.3 of the select2 library using the 'selectOnBlur' option.
这篇关于jQuery Select2标记模糊的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!