Hey community!
I’m trying to work with some repeaters, but I’m not sure if I should use any other system.
What I want to do is to be able to select different items on a modify them, just the ones that are selected. I need to remove the selected items from the database and insert them into a new one.
The code that I have now is this one:
import wixData from 'wix-data';
import wixUsers from 'wix-users';
$w.onReady(function () {
$w("#accept").onClick( (event) => {
let seleccionado = $w('#seleccionado').value === true;
let clickedItem = $w("#dataset1").getCurrentItem(seleccionado)['_id'];
$w("#applicants").forItems(clickedItem)
let saveApplication = {
"name": $w('#dataset1').getCurrentItem(seleccionado)['name'],
"email": $w('#dataset1').getCurrentItem(seleccionado)['email'],
"company": $w('#dataset1').getCurrentItem(seleccionado)['company']
};
wixData.insert("Accepted", saveApplication)
.then( (results) => {
let item = results; //see item below
} )
.then( () => {
$w("#dataset1").remove(seleccionado)
.then( () => {
console.log("Done removing current item");
} )
});
});
$w("#decline").onClick( () => {
if($w('#seleccionado').checked === true){
let clickedItemData = $w("#dataset1").getCurrentItem();
let saveApplication = {
"name": $w('#dataset1').getCurrentItem()['name'],
"email": $w('#dataset1').getCurrentItem()['email'],
"company": $w('#dataset1').getCurrentItem()['company']
};
wixData.insert("declined", saveApplication)
.then( (results) => {
let item = results; //see item below
} )
.then( () => {
$w("#dataset1").remove(clickedItemData)
.then( () => {
console.log("Done removing current item");
} )
});
}
});
But if I have 5 applications (items on the repeater), they only save and remove the last one uploaded, not the selected ones.
What should I do?
Thanks!!