I've got a simple bit of code I can't get working. It creates an entry into my Collection but the field values are empty - and the text input fields are filled in before submitButton is pressed.
import wixData from 'wix-data';
let toInsert = {
"title": $w("#title").value,
"region": $w("#region").value,
"price": $w("#price").value,
};
$w.onReady(function () {
});
export function submitButton_click(event) {
wixData.insert("Collection", toInsert);
}
Currently, the toInsert object is being assigned as the page loads when those elements have no value or have not been loaded yet. The object will have the values of the elements at the time the button is clicked if the code is placed at the top of the submitButton_click function.
Perfect, thank you Anthony