Closed renanmoraes closed 7 years ago
@renanmoraes , unfortunately the MaterializeCSS framework only supports passing the text and getting it back in the onAutocomplete
callback: http://materializecss.com/forms.html#autocomplete.
What I suggest you do is map your id (or original object) to the name, and get it using the value. Something like this:
const nameToObject = {};
this.autocompleteInit = {
'data': {},
onAutocomplete: (val) => {
console.log(nameToObject[val]);
},
};
data.forEach(o => this.autocompleteInit.data[o.name]=null);
data.forEach(o => nameToObject[o.name]=o);
I have the following array objects:
I need when typing the name of the city it will offer me the ones that correspond with the typed one. With standard array
{"Mines": null, "River": null}
works perfectly.I try to do it that way but it really does not work.
In reality, if I can get the id informed when it passes data
{"Mines": "123456"}
would serve me. When I do this, it returns me an error because I think I'm sending an image. I need to know when I clicked the _id of the clicked face.