移除jQuery用户界面自动完成微调,如果没有找到 [英] remove spinner from jquery ui autocomplete if nothing found

查看:73
本文介绍了移除jQuery用户界面自动完成微调,如果没有找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想删除微调(图片这表明,它是装载)从支持jQuery UI的自动完成文本字段。
由于没有事件不按源返回的结果一个不能触发这一点。

  $(#Q).autocomplete({
   来源:$ {建立连结(制图:'qsearch')},
   的minLength:2,
   选择:函数(事件,UI){
      富(ui.item.id);
   },
   搜索:函数(事件,UI){
      喇嘛();
   }
});


解决方案

从这里我的回答改编,添加以下code搜索后执行完成(甚至0结果):

  VAR __response = $ .ui.autocomplete.prototype._response;
$ .ui.autocomplete.prototype._response =功能(内容){
    __response.apply(这一点,[内容]);
    this.element.trigger(autocompletesearchcomplete,[内容]);
};

这code将触发一个事件( autocompletesearchcomplete ),然后可以绑定到:

  $(#Q)绑定(autocompletesearchcomplete功能(事件,内容){
    / *删除微调这里* /
});

希望有所帮助。

I want to remove the spinner (picture which shows that it is loading) from the textfield which supports jquery ui autocomplete. As there is no event for "no results returned by source" a can not trigger this.

$( "#q" ).autocomplete({
   source: "${createLink(mapping:'qsearch')}",
   minLength: 2,
   select: function( event, ui ) {
      foo( ui.item.id );
   },
   search: function( event, ui ) {
      bla();
   }
});

Adapted from my answer here, add the following code to execute after a search is complete (even with 0 results):

var __response = $.ui.autocomplete.prototype._response;
$.ui.autocomplete.prototype._response = function(content) {
    __response.apply(this, [content]);
    this.element.trigger("autocompletesearchcomplete", [content]);
};

That code will trigger an event (autocompletesearchcomplete) that you can then bind to:

$("#q").bind("autocompletesearchcomplete", function(event, contents) {
    /* Remove spinner here */
});

Hope that helps.

这篇关于移除jQuery用户界面自动完成微调,如果没有找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆