简体   繁体   中英

Better way to populate the options in a datalist

I have a datalist that contains 3360 options in a Flask application. I then have a input field which uses this list. The functionality I achieve with this is that a user can start typing a port name and the matching options show up in the dropdown. The problem is that this is quite slow, so I am trying to figure out if there is a way to use javascript with a json file to populate the datalist?

<datalist id="id_datalist">
    <option value="CLARENVILLE, CA">
    <option value="HOBRO, DK">
    ...

I believe what you need is a good old javascript autocomplete plugin from the time before <datalist> . This article describes some of the more popular ones (with examples), pick your favorite and implement it: https://www.sitepoint.com/14-jquery-live-search-plugins/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM