Jquery 自动完成功能未更新 UI 中的结果

发布于 2024-10-09 18:57:08 字数 1071 浏览 0 评论 0原文

我的 HTML 结构如下:

   <label for="supervisors">Assign the Supervisor: </label>
   <input class="supervisors"/>

我的 Javascript 是:

                  <script type="text/javascript">

                    jQuery(function() {

           jQuery( ".supervisors" ).autocomplete({
               source: "/users/autocomplete_for_supervisors",
               minLength: 2,
               select: function( event, ui ) {
                     log( ui.item ? "Selected: " + ui.item.value + " aka " + ui.item.id :
 "Nothing selected, input was " + this.value );


          }
        });
       });
              </script>

在我的控制器中,我添加了 autocomplete_for_supervisors 的操作,当我输入 URL 时,该操作正在工作:

http://localhost:3000/users/autocomplete_for_supervisors?term=ar

但是当我在 firebug 的输入框中输入一些内容时,jquery 就会被执行并调用相应的函数并在萤火虫中返回响应。但我没有在输入框中得到下面的响应。

如何在我的输入文本框中获取下面的返回结果?

请提供建议。

I have a HTML structure like:

   <label for="supervisors">Assign the Supervisor: </label>
   <input class="supervisors"/>

and my Javascript is:

                  <script type="text/javascript">

                    jQuery(function() {

           jQuery( ".supervisors" ).autocomplete({
               source: "/users/autocomplete_for_supervisors",
               minLength: 2,
               select: function( event, ui ) {
                     log( ui.item ? "Selected: " + ui.item.value + " aka " + ui.item.id :
 "Nothing selected, input was " + this.value );


          }
        });
       });
              </script>

and in my controller I have added the action for autocomplete_for_supervisors which is working when I gave in the URL as:

http://localhost:3000/users/autocomplete_for_supervisors?term=ar

But when I type something in the input box in my firebug the jquery is excuted and calling the respective function and returning the response in the firebug. But I am not getting the response below in the input box.

How do I get my returned result below in my input text box?

Please provide suggestions.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光磨忆 2024-10-16 18:57:08

我认为您在实际检索数据的函数/文件中使用了错误的变量名称。

这与我已解决的问题非常相似:Having issues with jQuery UI Autocomplete

I think you are usingthe wrong variable names in the function / file that actually retrieves your data.

This is very similar to my problem which got solved: Having problems with jQuery UI Autocomplete

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文