mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-23 08:36:32 +00:00
Post statuses asynchronously
This commit is contained in:
parent
71b2f91a73
commit
b0e7a5e468
1 changed files with 27 additions and 0 deletions
|
@ -22,6 +22,12 @@ let BookWyrm = new class {
|
||||||
this.interact.bind(this))
|
this.interact.bind(this))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
document.querySelectorAll('.submit-status')
|
||||||
|
.forEach(button => button.addEventListener(
|
||||||
|
'submit',
|
||||||
|
this.submitStatus.bind(this))
|
||||||
|
);
|
||||||
|
|
||||||
document.querySelectorAll('.hidden-form input')
|
document.querySelectorAll('.hidden-form input')
|
||||||
.forEach(button => button.addEventListener(
|
.forEach(button => button.addEventListener(
|
||||||
'change',
|
'change',
|
||||||
|
@ -292,6 +298,27 @@ let BookWyrm = new class {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post a status with ajax
|
||||||
|
*
|
||||||
|
* @param {Event} event
|
||||||
|
* @return {undefined}
|
||||||
|
*/
|
||||||
|
submitStatus(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
const bookwyrm = this;
|
||||||
|
const form = event.currentTarget;
|
||||||
|
|
||||||
|
this.ajaxPost(form).catch(error => {
|
||||||
|
// @todo Display a notification in the UI instead.
|
||||||
|
console.warn('Request failed:', error);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Clear form data
|
||||||
|
form.reset();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Submit a form using POST.
|
* Submit a form using POST.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue