Jquery 自动完成功能未更新 UI 中的结果
我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您在实际检索数据的函数/文件中使用了错误的变量名称。
这与我已解决的问题非常相似: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