sergiodlopes / jquery-flexdatalist

Flexible input autocomplete/datalist plugin for jQuery
http://projects.sergiodinislopes.pt/flexdatalist/
MIT License
365 stars 84 forks source link

Search multiple data sources for faster search results #248

Open handiworknyc opened 1 year ago

handiworknyc commented 1 year ago

@sergiodlopes

$oginput.flexdatalist({
    minLength: 2,
    valueProperty: '*',
    searchContain: true,
    normalizeString: function (string) {
        return string.toLowerCase();
    },
    visibleProperties: ["title", "par_title", "type", "url"],
    searchIn: 'title',
    data: siteurl + '/search-data'
});

I'm using flexdatalist here: https://wtgrantfdn.xyz/the-library ...

the data loaded from the URL https://wtgrantfdn.xyz/search-data is quite large (1000s of rows) and there is a delay of several seconds between typing and the results rendering.

What I would like to do:

  1. load a much smaller JSON array only with popular searches directly to the page (no ajax request necessary)
  2. search this array initially
  3. and if no results are found in the smaller array, then make the ajax request to the full array.

Any help with regards to how to code this logic is much appreciated.

Thanks!