Using an array as the data source #199
-
Hello! I hope this is the right place to ask this question. I'm currently working on building a search feature that goes through all the tags in my blog which are stored in an array. I'm stumped on the syntax of how to set the autoComplete engine to use it as it's "database". Any help/guidance would be very much appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hello @TCRodriguez, If your data is just an array of strings you'll just have to point the const tags = ["tag1", "tag2", "tag3"];
data: {
src: tags
} In case it's an array of const tags = [{name: "tag1"}, {name: "tag2"}, {name: "tag3"}];
data: {
src: tags,
key: ["name"]
} Try it, and let me know-how it goes. Have a nice day! :) |
Beta Was this translation helpful? Give feedback.
Hello @TCRodriguez,
If your data is just an array of strings you'll just have to point the
data.src
to that array as shown below.In case it's an array of
Objects
you'll need to add the key that theautoComplete.js
engine will be looking for as shown below.Try it, and let me know-how it goes.
Have a nice day! :)