Open jturmel opened 4 years ago
I overload the froala-django.js file within my projects with this version that fixes the issue. The problem is the invalid called to jQuery along with the javascript on the page not allowing inline formsets to generate the editors as the prefix is not being replace in the cloned script tag. This fixes that
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i].trim();
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
if (typeof django !== 'undefined' && typeof django.jQuery !== 'undefined') {
(function ($) {
$(document).on('formset:added', function (event, $row, formsetName) {
$row.find('textarea').each(function () {
var parts = this.closest('tr').id.split('-');
var froala_script = this.nextElementSibling.innerText.replace('__prefix__', parts[parts.length-1]);
froala_script = froala_script.replace("\n","");
this.parentElement.innerHTML = this.outerHTML;
var additional_script = document.createElement("script");
additional_script.textContent = froala_script;
document.head.appendChild((additional_script));
});
});
})(django.jQuery);
}