You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
problem is that qutocomplete doesnt wait until my fetch is complete and show old results, can someone tell me how I can prevent this and force it to wait until my data come back?
heres code
vartoken='<?php echo $token; ?>';constautoCompleteJS=newautoComplete({placeHolder: "<?php echo $help_address; ?>",data: {src: [],cache: false,},resultItem: {highlight: true},trigger: async(query)=>{if(query.length>=autoCompleteJS.threshold-1){suggest(query);returntrue;}returnfalse;//return query.replace(/ /g, "").length; // Returns "Boolean"},query: function(input){returninput;},events: {input: {selection: function(event){constselection=event.detail.selection.value;//console.log(selection)this.value=selection;},open(){}}},resultsList: {element: (list,data)=>{data.results=data.results.filter((el,index)=>{if(el.value.includes('Riga')==false){varelement=document.getElementById("autoComplete_result_"+index);list.removeChild(element);returnfalse;}returntrue;})if(!data.results.length){// Create "No Results" message list elementconstmessage=document.createElement("div");message.setAttribute("class","no_result");// Add message text contentmessage.innerHTML=`<span>Found No Results for "${data.query}"</span>`;// Add message list element to the listlist.appendChild(message);}},noResults: true,maxResults: 20,},threshold: 3,debounce: 200,});asyncfunctionsuggest(resource){letinput=document.querySelector("#autoComplete").valueconstapi=document.querySelector("input[name=qwqer_api]").value;constpt=document.querySelector("input[name=qwqer_trade_pt]").value;letdata=newFormData()data.append("api_token",api);data.append("trade_point",pt);data.append("input",input);autoCompleteJS.data.src=awaitfetch('index.php?route=extension/shipping/qwqer/autocomplete&token=<?php echo $token; ?>',{method: "POST",body: data,}).then((response)=>{// 1. check response.okif(response.ok){returnresponse.json();}returnPromise.reject(response);// 2. reject instead of throw}).then((data)=>{returndata.data;//autoCompleteJS.data.keys = ["title"];}).catch(response=>{response.json().then((json)=>{console.log(json.message);})});returnautoCompleteJS.data.src}
The text was updated successfully, but these errors were encountered:
Hi I am trying to fetch data on key input using your library but i cant find a proper solution with your library,
heres a problem i am facing
heres a graph https://i.imgur.com/j0wFveh.png.
problem is that qutocomplete doesnt wait until my fetch is complete and show old results, can someone tell me how I can prevent this and force it to wait until my data come back?
heres code
The text was updated successfully, but these errors were encountered: