Skip to content

Commit

Permalink
Reinitialize froala for textarea in newly added admin inline; fixes #40
Browse files Browse the repository at this point in the history
  • Loading branch information
isDipesh committed Mar 14, 2018
1 parent 17c84d6 commit 4453402
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions froala_editor/static/froala_editor/js/froala-django.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
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 = jQuery.trim(cookies[i]);
// 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;
}
}
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// 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;
}
return cookieValue;
}

if (typeof django !== 'undefined') {
(function ($) {
$(document).on('formset:added', function (event, $row, formsetName) {
$row.find('textarea').each(function () {
$(this).prev().remove();
jQuery(this).froalaEditor();
});
});
})(django.jQuery);
}

0 comments on commit 4453402

Please sign in to comment.