需要使用TomSelect的最小滤波器输入长度(例如Select2'最低限量)
我有一个带有多选字段的网页以用于名称,并且为了防止偏见,我只想在用户将至少3个字符输入过滤器/搜索字段后向用户显示列表条目。
是什么是最佳的方法来实现这一目标? tomSelect for tomSelect for tomSelect for tomSelect in terme
设置可能是一种说明:
使用showsload()回调来实现最小输入长度或其他输入验证。如果回调返回false,则不会调用load(),并且NOT_LOADING模板将添加到下拉列表而不是加载或NO_RESULTS模板中。
但是,似乎应该载荷
仅限制load()
将被调用以获取远程资源的其他结果,但是所有已经可用的结果都将始终显示,不管shore shore load
返回()。
I have a webpage with a multi-select field for names, and to prevent biases, I want to only show list entries to users after they have entered at least 3 characters into the filter/search field.
Select2 supports this using the minimumInputLength
setting (jsbin)
What would be the best way to achieve this with TomSelect?
jsbin-template for tomselect here
Their documentation lists the shouldLoad
setting as a possibility, with this explanation:
Use the shouldLoad() callback to implement minimum input length or other input validation. If the callback returns false, load() will not be called and the not_loading template will be added to the dropdown instead of the loading or no_results templates.
However, it seems that shouldLoad
only limits whether load()
will be called to fetch additional results from the remote resource, but any results that are already available will always be shown, no matter what shouldLoad
returns (jsbin mre).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
应该有效有效,当您满足查询时,您必须在回调中返回, load 只有在返回应负载的返回时,才会调用API?
您可以设置Minimun,Regex或您想要的任何验证。
为了删除先前的结果,您可以使用 clear()清除选定的选择,并在每个加载之前 emoveItem 。
shouldLoad works, you have to return on callback when you satisfy with the query, load will only call the api if the return of shouldLoad is true shouldLoad?
You can set minimun, regex, or any validation that you want.
For remove your previous results, you can use clear() to clear selected and removeItem before each load.