devbridge / jQuery-Autocomplete

Ajax Autocomplete for jQuery allows you to easily create autocomplete/autosuggest boxes for text input fields
https://www.devbridge.com/sourcery/components/jquery-autocomplete/
Other
3.57k stars 1.67k forks source link

modify query before performing ajax lookup #849

Closed kvonspiczak closed 1 year ago

kvonspiczak commented 1 year ago

i'm trying to modify the submitted query before showing the suggestions. so in my specific case: if someone enters a query and it ends with a -, I want the autocomplete to treat the query as if it was without the - at the end. any tips, how to accomplish that?

gongph commented 1 year ago

这是来自QQ邮箱的假期自动回复邮件。你好,我最近正在休假中,无法亲自回复你的邮件。我将在假期结束后,尽快给你回复。

tkirda commented 1 year ago

You can manipulate query by updating it using onSearchStart (this is for Ajax lookup):

onSearchStart: (params) => {
  params.query = _.trimEnd(params.query, '-');
}