// 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'; }); }); });