Manual code that redirects to the item that has been created


What is the code that manually redirects to the item’s page, after being submitted ? I know it is possible to do this by configurating the ‘submit’ button, only I have some code that executes before, and sometimes this function doesn’t work, I suppose that’s because it conflicts with the code.

Thanks !

Hi Tristan!

Please check this wix-Location API .
You can add its functionality to your submit button after it executes the code you desire.

Hope it helps!
Best of luck!

Doron. :slight_smile:

I don’t see how to get the url of the page that’s been created after submitting the item.

Hi Tristan!

While inserting an item to a database an item._ID is being generated automatically.
Use this wixData API and add the code to your submit button (after the insertion a promise is returned containing the item._id) .
It suppose to look something like that:

export function submitButton_click() {
	wixData.insert("myCollection", toInsert)
		.then((item) => {
			let id = item._id;`/Items/${id}`);

Just make sure all the fields/functions/collections has the same name as the relevant ones in your site.

Doron. :slight_smile: