Hi.
I’m using Wix Studio and have a dynamic item page linked to a collection dataset.
On this page, I have a button to delete the collection record.
I’m using the following code:
export function buttonDelAct_click(event) {
$w('#dynamicDataset').onReady(()=> {console.log('Dynamic-Dataset ready...');
let curItem = $w('#dynamicDataset').getCurrentItem(); console.log('Current-Item: ', curItem)
let userObjectId =curItem._id; console.log('User Object Id: ', userObjectId);
wixData.remove("astrouserobjects", userObjectId)
.then((result) => {
console.log(result); // see removed item below
wixLocationFrontend.to("/astroobjectsindex-user");
})
.catch((err) => {
console.log(err);
});
});
When I click the button nothing happens.
However, when I view the page in preview in the editor and I click the button it works.
The collection record is deleted and I am redirected to the page, /astroobjectsindex-user.
Any idea how to fix this?
Many thanks
Mark