Hi Guys thanks for all your help.
I have created a user form to add properties to my rental site. It works great but the Lightbox I have on confirmation (submit) pops up straight away, instead of after my images have uploaded. Is there any way to delay this until the data is ACTUALLY submitted to the collection? (Still a WIP btw!) TIA
Form here:
https://pete092.wixsite.com/book-the-best/add-property
My code:
import wixWindow from ‘wix-window’;
import wixData from ‘wix-data’;
export function submit_click(event, $w) {
$w(“#group24”).show();
console.log(“saving”);
//Send a blank message to the HTML element. This tells the HTML
//element you want it to send you its contents
$w(“#html1”).postMessage(" “);
//Receive the message from the HTML element
$w(”#html1").onMessage((event) => {
//Set the value for the rich text field of the dataset’s
//current item to be the data in the HTML element
$w(“#dataset2”).setFieldValue(“longDescription”, event.data);
//Submit the current item of the dataset
$w(“#dataset2”).save()
.then((res) => {
console.log(“saving”, res);
});
wixWindow.openLightbox(‘SAVED’);
});
}
Hi,
Try to move this line: wixWindow.openLightbox(‘SAVED’); to “.then” scope.
Roi
Thanks Roi, but this breaks the code (it just says saving in the console, but nothing ever happens)…or am I not putting it in right?
import wixWindow from ‘wix-window’;
import wixData from ‘wix-data’;
export function submit_click(event, $w) {
$w(“#group24”).show();
console.log(“saving”);
//Send a blank message to the HTML element. This tells the HTML
//element you want it to send you its contents
$w(“#html1”).postMessage(" “);
//Receive the message from the HTML element
$w(”#html1").onMessage((event) => {
//Set the value for the rich text field of the dataset’s
//current item to be the data in the HTML element
$w(“#dataset2”).setFieldValue(“longDescription”, event.data);
//Submit the current item of the dataset
$w(“#dataset2”).save()
.then((res) => {
console.log(“saving”, res);
$w(“#group24”).hide();
wixWindow.openLightbox(‘SAVED’);
});
});
}
And I also have a similar form to ‘edit’ the properties which displays the text from the collection in the rich text editor (works perfectly). However, once again when I submit nothing happens:
export function submit_click(event, $w) {
//Send a blank message to the HTML element. This tells the HTML
//element you want it to send you its contents
$w(‘#group25’).show();
$w(“#html1”).postMessage(“save”);
//Receive the message from the HTML element
$w(“#html1”).onMessage((event) => {
//Set the value for the rich text field of the dataset’s
//current item to be the data in the HTML element
$w(“#dynamicDataset”).setFieldValue(“longDescription”, event.data);
//Submit the current item of the dataset
$w(“#dynamicDataset”).save()
.then((res) => {
$w(‘#group25’).hide();
$w(“#PropertyInfo”).value = null;
$w(“#Location”).selectedIndex = undefined;
$w(“#Type”).selectedIndex = undefined;
$w(“#Guests”).selectedIndex = undefined;
$w(“#Bedrooms”).selectedIndex = undefined;
$w(“#Bathrooms”).selectedIndex = undefined;
});
});
}
HTML element:
<!doctype html>
Also has an onready function:
$w.onReady(function () {
$w(“#dynamicDataset”).onReady(() => {
const msg = $w(“#dynamicDataset”).getCurrentItem();
$w(“#html1”).onMessage((event) => {
if (event.data === “ready”) {
$w(“#html1”).postMessage(msg.longDescription);
}
});
});
});
Page is a dynamic one called /Properties/edit/{Title}
Thanks for checking it out Roi!
Roi? Or Sam are you here please
Hi,
Can you please share a link to your site and specify the name of the relevant page ?
Roi
Thanks Roi, look forward to your help!