We are at the start of getting UPDATE support properly set up.
This commit is contained in:
parent
dbf0d6169a
commit
8a3eb2c2ef
3 changed files with 194 additions and 18 deletions
|
|
@ -41,6 +41,7 @@
|
|||
document.getElementById("{{ field['attrs']['data-model'] }}_form").addEventListener("submit", async e => {
|
||||
e.preventDefault();
|
||||
const json = formToJson(e.target);
|
||||
json['id'] = {{ field['template_ctx']['values']['id'] }};
|
||||
|
||||
response = await fetch("{{ url_for('entry.update_entry', id=field['template_ctx']['values']['id'], model=field['attrs']['data-model']) }}", {
|
||||
method: "POST",
|
||||
|
|
@ -52,9 +53,9 @@
|
|||
|
||||
reply = await response.json();
|
||||
if (reply['status'] === 'success') {
|
||||
console.log("WELL DONE!")
|
||||
toastMessage("This entry has been successfully saved!", "success");
|
||||
} else {
|
||||
console.log("YOU HAVE FAILED!")
|
||||
toastMessage(`Unable to save entry: ${reply['error']}`, "danger");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
Loading…
Add table
Add a link
Reference in a new issue