简体   繁体   English

如何使用 YUI 3 自动完成“强制选择”?

[英]How to “force selection” with YUI 3 Autocomplete?

I am using YUI 3 to create an autocomplete box in which I would like to force the selection and require the user to select a result from the container, or else the input field is cleared of whatever value they have typed in manually.我正在使用 YUI 3 创建一个自动完成框,我想在其中强制选择并要求用户 select 来自容器的结果,否则输入字段将清除他们手动输入的任何值。 forceSelection was a feature in the YUI 2 Autocomplete widget and info here . forceSelectionYUI 2 Autocomplete widget中的一项功能,此处提供信息。 But... it does not look like it has been added to the new YUI 3 version yet.但是……看起来它还没有被添加到新的YUI 3 版本中。 here's the open ticket.这是开票。 I would just use YUI 2 Autocomplete, however I am already using other improved features that came with YUI 3.我只会使用 YUI 2 自动完成功能,但是我已经在使用 YUI 3 附带的其他改进功能。

Is there an easy way to implement this manually for YUI 3?有没有一种简单的方法可以为 YUI 3 手动实现?

Ryan Grove from the YUI team recently posted this: YUI 团队的 Ryan Grove 最近发布了这个:

This feature is currently targeted for 3.5.0.此功能目前针对 3.5.0。 In the meantime, it's not too hard to implement forced selection by hooking into AutoComplete events.同时,通过挂钩到 AutoComplete 事件来实现强制选择并不难。 Here's a very basic example that you could build on: http://jsfiddle.net/rgrove/aJcqt/这是您可以构建的一个非常基本的示例: http://jsfiddle.net/rgrove/aJcqt/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM