【问题标题】:jQuery TypeWatch - Extending for empty input?jQuery TypeWatch - 扩展空输入?
【发布时间】:2010-10-15 17:19:07
【问题描述】:

我已经使用 ajax 创建了自己的自动完成功能,并且我希望能够在用户键入时监控搜索输入...我现在正在使用 TypeWatch,我看到的唯一问题是如果用户退格了现在输入是空的,我的搜索结果就在那里。

扩展 TypeWatch 函数(可能添加第二个回调)以便当输入为空时,我可以删除搜索结果 div 的最佳方法是什么?

【问题讨论】:

    标签: jquery autocomplete typewatch


    【解决方案1】:

    试试这个:

    在 typeWatch.js 中,在 checkElement() 函数中添加一行:

      // Fire if text > options.captureLength AND text != saved txt OR if override AND text > options.captureLength, OR if the results are empty and there was a previous search
      if ((elTxt.length > options.captureLength && elTxt.toUpperCase() != timer.text)
      || (override && elTxt.length > options.captureLength)
      || (elTxt.length == 0 && timer.text)
      ) {
        timer.text = elTxt.toUpperCase();
        timer.cb(elTxt);
      }
    };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-15
      • 2010-09-12
      • 1970-01-01
      • 2014-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多