Hello,
I have some trouble from one week ago with getItems() fuction:
It’s look like the fonction have one lap of delay:
When I change the selection of my dropdown
the value of Item is the value of the selection N-1…
but the value of the dropdown if good…
I’m French and some comment are in french on the code
best regard
import wixWindow from 'wix-window';
import wixData from 'wix-data';
import wixUsers from 'wix-users';
//-------------Global Variables-------------//
// Options that have been selected.
let item={};
let txt_param = {1:'',2:'',3:'',4:'',5:''};
let param= {1:false,2:false,3:false,4:false,5:false};
//standard function
function ReadItem(Dataset,index){
$w(`#${Dataset}`).getItems(index,1)
.then( (result) => {
$w(`#${Dataset}`).onReady( () => {
item = result.items[0];
});
});
}
//standard form
export function selectFormButton_change(event) {
$w('#selectDesignButtonOp').enable();
let test = $w('#selectFormButton').selectedIndex;
console.error(test);
ReadItem('dataset1',test);
console.error(item);
let txt_tmp= item.title + ';' +
item.doigt1 + ';' +
item.doigt2 + ';' +
item.doigt3 + ';' +
item.doigt4 + ';' +
item.doigt5 + ';' +
item.doigt6 + ';' +
item.doigt7 + ';' +
item.doigt8 + ';' +
item.doigt9 + ';' +
item.doigt10;
$w('#Parametre').text = ParamUpdate(1,txt_tmp,1);
}
thanks for your answer. Yes sorry, the onready() it’s mistask of me, I have add this for “try”.
my original function was this and it’s working one weeks ago (the function return nothing but if I print ‘tmp’ on the console before ‘return’ the value is ok):
function ReadItem(Dataset,index){
let tmp=[];
$w(`#${Dataset}`).getItems(index,1)
.then( (result) => {
tmp = result.items;
});
return tmp[0];
}
I have modify my dropdown fuction like this , it’s not exactly what i expected but it’s work:
Yes, All data was in correct place. but ok. the problem is when I try to extract the data outside of getItem function.
If I do Everything inside “getItems()”. it’s working, I will continue On this way…