繁体   English   中英

文本输入上的 Select2 4.0.5 触发事件

[英]Select2 4.0.5 trigger event on Text input

在 select2 的早期版本中,我可以在输入搜索框时使用 select2-selecting 触发一个事件。 在 4.0.5 中,使用 select2:selecting,它似乎不再起作用了。 有人知道可行的解决方案吗? 每次我在 select2 的搜索栏中键入内容时,我都想向我的服务器发送一个 ajax 请求。 就像我在早期版本中所说的那样,这是可能的! 感谢您的任何建议。

您必须将 select2 放在 4.x 中的选择项上

https://select2.org/data-sources/ajax

按照那个例子做了,它奏效了。

我不得不将 html 元素从输入更改为选择。 输入适用于旧版本的 select2,但不适用于 4.x

旧的html

<input id="groupSelect" name="group_id" type="text" style="max-width: 100%; width: 100%;" required>

新的 html

<select id="groupSelect" name="group_id" type="text" style="max-width: 100%; width: 100%;" required></select>

暂无
暂无

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

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