Reputation: 83
So I want to create a drag&drop feature on my website (not the file uploading way, but the way to move things around as a user). To achieve this, I am planning to use an HTML embed, which basically covers the whole site. This way, I am able to control everything on the website. Currently, I am creating a backend script to read the data out of my database. Now I am asking myself whether I will be able to use that very script in my code? Or is my HTML embed completely isolated? Thank you for your help!
import { sql } from '@velo/wix-data-sql-backend';
export async function fetchData() {
try {
const results = await sql("SELECT * FROM collection;");
return results.payload.data.rows;
} catch (error) {
console.error(error);
}
}
Upvotes: 0
Views: 946
Reputation: 1109
You can definitely communicate between an HTML Component and a page in Wix using the postMessage()
and onMessage()
functions.
As a side point, you might want to consider using a Custom Element instead of an HTML Component. You can also communicate between a Custom Element and a page using the setAttibute()
and on()
functions.
Upvotes: 1