xxxxxxxxxx
1
<div id="basic" class="form-outline" data-mdb-input-init>
2
<input id="testId" type="text" name="" class="form-control input_small recipe_process_ingredient_name" placeholder="Recipe" >
3
</div>
4
<script src="https://code.jquery.com/jquery-3.7.1.slim.min.js" integrity="sha256-kmHvs0B+OpCW5GVHUNjv9rOmY0IvSIRcf7zGUDTDQM8=" crossorigin="anonymous"></script>
1
1
xxxxxxxxxx
1
$(document).on("keyup",".recipe_process_ingredient_name",function(){
2
console.log('d')
3
const $input = $(this);
4
const asyncFilter = async (query) => {
5
const url = `https://swapi.py4e.com/api/people/?search=${encodeURI(query)}`;
6
const response = await fetch(url);
7
const data = await response.json();
8
return data.results;
9
};
10
mdb.Autocomplete.getOrCreateInstance($input.parent().get(0), {
11
filter: asyncFilter,
12
displayValue: (value) => value.name
13
});
14
});
Console errors: 0