Button on dynamic item page page not working

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

if it works on the preview, but not on the live site it is most likely the permissions on the dataset. The preview works in admin mode.

Hi Dan.

Many thanks. I changed the permission, “Can delete content”, on the collection and this resolved the problem.

Many thank

Mark

1 Like