jQuery加载函数后,jQuery UI自动完成功能不起作用
jQuery UI autocomplete is not working after jQuery load function
我正在尝试使用jQuery UI自动完成函数,它非常有效,直到我用jQuery load()函数替换数据。在这之后,一切都不起作用——一片寂静。
我的html代码如下:
<div class="ui-widget">
<label for="search">Search: </label>
<input id="search">
</div>
我的js代码:
function enableAutocomplete(){
$( "#search" ).autocomplete({
source: function( request, response ) {
$.getJSON( "/Controller/search", {
term: request.term
}, response );
},
minLength: 2,
select: function( event, ui ) {
(...something going on here, doesn't matter...)
}
});
}
}
load()成功返回后,我调用enableAutocomplete()将自动完成事件与我选择的元素再次绑定。我在这个论坛的某个地方读到,我应该这么做。但从那时起,什么都没发生。键入后永远不会调用自动完成。我在控制台中调试了它,并将所有内容记录在时间表中(Chrome开发工具),就像我说的那样,这里完全安静。有人知道吗,为什么??
你能试试这个吗
function _debugResponse(respData,txt,xhr){console.log('Debug server response'); console.log(respData);}
function enableAutocomplete() {
console.log('enableAutocomplete called');
$("#search").autocomplete({
source: function (request, response) {
console.log('autocomplete.source method called');
$.getJSON("/Controller/search", { term: request.term }, _debugResponse );
},
minLength: 2,
select: function (event, ui) { console.log(event) }
});
}
enableAutocomplete();
然后在开发控制台上发布你得到了什么?
相关文章:
- jQuery成功函数中的ajax成功函数
- jQuery触发器点击未从AJAX成功工作
- 将值传递到jQuery成功函数中的引导模式
- jQuery成功,访问HTTP状态文本
- jQuery成功处理程序未在生产服务器上执行,但在dev中运行良好
- 为什么jQuery成功回调有时有3个参数,有时只有1个
- 当 AJAX 响应成功时清除 jquery 成功/错误消息 span 类
- 如何在 jquery 成功方法中接收 JSON 并使用该 JSON 构建 HTML 内容
- 如何在 jquery 成功方法中接收其他参数 ()
- Ajax JQuery成功函数不工作
- AJAX jQuery成功,但没有改变
- 在JQUERY成功时调用函数
- jQuery成功后,重新加载页面,然后追加
- 如何在jQuery成功的情况下执行查询?
- JQuery成功函数未触发
- jQuery:成功传递变量给函数$.get请求
- 使用JQuery成功上传表单到Django App
- 无法从jquery's成功传递值给javascript函数
- 如何在使用Ajax/Jquery成功提交表单后隐藏表单
- 使用jQuery成功刷新DIV