Unlayer Help
Copy Below Code
View As A Text File
Show Text Only
Show API
Edit Code
function exportCodeAhab() {
editor1.exportHtml(function (data) {
// Retrieve the current HTML content
let htmlContent = data.html;
// Define the text to add at the bottom
const footerText = `
<div style="text-align: center; margin-top: 20px; font-size: 14px; color: #555;">
<p>This is a custom footer text added to the template.</p>
</div>
`;
// Append the footer text to the existing HTML
htmlContent += footerText;
// Optional: Display the updated HTML in the console (for debugging)
console.log(htmlContent);
// Perform further actions with the updated HTML (e.g., save it, download it, etc.)
// Example: Save the updated HTML via an AJAX request
saveUpdatedTemplate(htmlContent);
});
}
// Example function to save the updated template via AJAX
function saveUpdatedTemplate(updatedHtml) {
fetch('/save-template', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content'),
},
body: JSON.stringify({ html: updatedHtml }),
})
.then(response => response.json())
.then(data => {
if (data.success) {
alert('Template saved successfully!');
} else {
alert('Failed to save template.');
}
})
.catch(error => {
console.error('Error:', error);
});
}