Spaces:
Running
Running
File size: 1,048 Bytes
54fc73e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | // Image preview functionality for create/edit forms
document.addEventListener('DOMContentLoaded', function() {
// Image upload preview
const imageInput = document.getElementById('image');
if (imageInput) {
imageInput.addEventListener('change', function(e) {
const file = e.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function(event) {
document.getElementById('image-preview').src = event.target.result;
};
reader.readAsDataURL(file);
}
});
}
// Form submission handling
const forms = document.querySelectorAll('form');
forms.forEach(form => {
form.addEventListener('submit', function(e) {
e.preventDefault();
// In a real app, this would submit to Django backend
alert('Form submitted! In a real app, this would save to the database.');
window.location.href = '/blog';
});
});
}); |