truckingsim / Ajax-Bootstrap-Select

This uses the bootstrap-select plugin and extends it so that you can use a remote source to search.
MIT License
280 stars 97 forks source link

Search occurs when deleting query #155

Closed Folkman closed 5 years ago

Folkman commented 6 years ago

When the minLength option is set, a search occurs when it reaches the minLength. For example, if the minLength is 3, and you typed in Tommy, but then decided you wanted Bob, while you are backspacing, it performs a search at Tom, and with long search results, you have to wait until the Tom results load before typing Bob. Moving clearTimeout before checking minLength solves this issue.

// Clear out any existing timer.
clearTimeout(requestDelayTimer);

// Don't process if below minimum query length
if (query.length < plugin.options.minLength) {
    plugin.list.setStatus(plugin.t('statusTooShort'));
    return;
}