jQuery UI自动完成:从不弹出?
有没有什么方法可以告诉jQueryUIAutoComplete永远不要搜索?我想我可以把jQuery UI自动完成:从不弹出?,jquery,jquery-ui,jquery-ui-autocomplete,Jquery,Jquery Ui,Jquery Ui Autocomplete,有没有什么方法可以告诉jQueryUIAutoComplete永远不要搜索?我想我可以把minLength设置得很高,但有没有合适的方法呢 如果您想知道,我将用onclick事件手动触发它 如何添加onclick处理程序: if(settings.showOnClick) { $(this).bind('click.ajaxselect', function(e) { if(!$(this).data('focusHandled') && !$(this
minLength
设置得很高,但有没有合适的方法呢
如果您想知道,我将用onclick事件手动触发它
如何添加onclick处理程序:
if(settings.showOnClick) {
$(this).bind('click.ajaxselect', function(e) {
if(!$(this).data('focusHandled') && !$(this).autocomplete('widget').is(':visible')) {
$(this).autocomplete('search','');
$(this).data('focusHandled',true);
} else {
$(this).data('focusHandled',false);
}
}).bind('focus.ajaxselect', function(e) {
if(!$(this).data('focusHandled') && e.hasOwnProperty('originalEvent') && $(this).val() === this.defaultValue && !$(this).autocomplete('widget').is(':visible')) {
$(this).autocomplete('search','');
$(this).data('focusHandled',true);
} else {
$(this).data('focusHandled',false);
}
})
}
将
minLength
设置为您想要的任何值(可能是0,因为您手动触发)。那么
将其放入
搜索
回调似乎可以实现我想要的大部分功能:
search: function(e, ui) {
if(settings.minLength < 0 && e.hasOwnProperty('originalEvent')) return false;
// other code
return true;
},
搜索:功能(e、ui){
if(settings.minLength<0&&e.hasOwnProperty('originalEvent'))返回false;
//其他代码
返回true;
},
然后,如果我将
minLength
设置为小于0,则键入事件不会触发搜索,但我的手动单击事件仍然会触发搜索。不过,焦点活动似乎也被取消了。正在尝试确定我是否对这种行为感到满意。禁用它似乎会取消搜索,甚至在单击时也是如此。您是如何激活单击时自动完成的?
search: function(e, ui) {
if(settings.minLength < 0 && e.hasOwnProperty('originalEvent')) return false;
// other code
return true;
},