ADD ITEM TO THE LIBRARY PAGE
import wixData from 'wix-data';
function clearFields(fieldKeys) {
fieldKeys.forEach(fieldKey => {
let field = $w('#' + fieldKey);
if (field.type === $w("#signature").type) {
field.clear();
} else {
field.value = null;
}
if (field.validity.valueMissing) {
field.resetValidityIndication();
}
});
}
export function submitButton_click(event) {
let toInsert = {
"firstName": $w("#firstName").value,
"comments": $w("#comments").value,
"signature": $w('#signature').value
};
wixData.insert("ThankYouNote", toInsert)
.then((results) => {
let item = results; //see item below
$w('#successMessage').show();
clearFields(Object.keys(item));
console.log(item);
})
.catch((err) => {
let errorMsg = err;
});
}
/* item:
*
* {
* _id: "41c8ef87-3eec-47bd-a3bd-17a09de9ffee"
* _owner: "4c47c608-cfa8-4037-93ac-738f09560ed3"
* _createdDate: "2019-11-10T09:27:14.605Z"
* _updatedDate: "2019-11-10T09:27:14.605Z"
* title: "Mia"
* lastName: "Casa"
* email: "MiaCasa@SuCasa.com"
* signature: "data:image/png;base64,iVBORw0KGgoAAAANSUhEU...AAAASUVORK5CYII="
* }
*/
On the signature page
// API Reference: https://www.wix.com/corvid/reference
// “Hello, World!” Example: https://www.wix.com/corvid/hello-world
$w.onReady(function () {
// Write your JavaScript here
// To select an element by ID use: $w("#elementID")
// Click "Preview" to run your code
});
Allow User to add stuff to a page, like on helpunited.org - signing the thank you card.
import wixData from 'wix-data';
function clearFields(fieldKeys) {
fieldKeys.forEach(fieldKey => {
let field = $w('#' + fieldKey);
if (field.type === $w("#signature").type) {
field.clear();
} else {
field.value = null;
}
if (field.validity.valueMissing) {
field.resetValidityIndication();
}
});
}
export function submitButton_click(event) {
let toInsert = {
"firstName": $w("#firstName").value,
"comments": $w("#comments").value,
"signature": $w('#signature').value
};
wixData.insert("ThankYouNote", toInsert)
.then((results) => {
let item = results; //see item below
$w('#successMessage').show();
clearFields(Object.keys(item));
console.log(item);
})
.catch((err) => {
let errorMsg = err;
});
}
/* item:
*
* {
* _id: "41c8ef87-3eec-47bd-a3bd-17a09de9ffee"
* _owner: "4c47c608-cfa8-4037-93ac-738f09560ed3"
* _createdDate: "2019-11-10T09:27:14.605Z"
* _updatedDate: "2019-11-10T09:27:14.605Z"
* title: "Mia"
* lastName: "Casa"
* email: "MiaCasa@SuCasa.com"
* signature: "data:image/png;base64,iVBORw0KGgoAAAANSUhEU...AAAASUVORK5CYII="
* }
*/
From page with the card.
// API Reference: https://www.wix.com/corvid/reference
// “Hello, World!” Example: https://www.wix.com/corvid/hello-world
$w.onReady(function () {
// Write your JavaScript here
// To select an element by ID use: $w("#elementID")
// Click "Preview" to run your code
});