mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 10:11:09 -05:00
Refactor ride form template to utilize Alpine.js for state management. Enhanced form submission handling and improved search result clearing functionality for better user experience.
This commit is contained in:
@@ -199,24 +199,31 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.body.addEventListener('htmx:afterRequest', function(evt) {
|
||||
if (evt.detail.successful) {
|
||||
const path = evt.detail.requestConfig.path;
|
||||
let event;
|
||||
|
||||
if (path.includes('approve')) {
|
||||
event = new CustomEvent('submission-approved');
|
||||
} else if (path.includes('reject')) {
|
||||
event = new CustomEvent('submission-rejected');
|
||||
} else if (path.includes('escalate')) {
|
||||
event = new CustomEvent('submission-escalated');
|
||||
} else if (path.includes('edit')) {
|
||||
event = new CustomEvent('submission-updated');
|
||||
}
|
||||
|
||||
if (event) {
|
||||
window.dispatchEvent(event);
|
||||
}
|
||||
document.addEventListener('alpine:init', () => {
|
||||
Alpine.data('moderationDashboard', () => ({
|
||||
init() {
|
||||
// Handle HTMX events using AlpineJS approach
|
||||
document.body.addEventListener('htmx:afterRequest', (evt) => {
|
||||
if (evt.detail.successful) {
|
||||
const path = evt.detail.requestConfig.path;
|
||||
let eventName;
|
||||
|
||||
if (path.includes('approve')) {
|
||||
eventName = 'submission-approved';
|
||||
} else if (path.includes('reject')) {
|
||||
eventName = 'submission-rejected';
|
||||
} else if (path.includes('escalate')) {
|
||||
eventName = 'submission-escalated';
|
||||
} else if (path.includes('edit')) {
|
||||
eventName = 'submission-updated';
|
||||
}
|
||||
|
||||
if (eventName) {
|
||||
this.$dispatch(eventName);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}));
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user