The editor doesn't work with new inlines in the admin that are created with javascript. If you press the "Add a new row" button, the editor shows up, but it doesn't update the hidden textarea. This happens, because the html is not updated correctly. The javascript produces something like this:
</div></trix-toolbar><trix-editor input="id_aboutintrotext_set-__prefix__-text" class="trix-content" contenteditable="" trix-id="2" toolbar="trix-toolbar-2"><div><!--block-->fdssadfdsafdssassa</div></trix-editor></p>
Notice the "__prefix__" is still there.
I was able to work around this by making my own copy of static/admin/js/inlines.js and adding a few lines:
var updateElementIndex = function(el, prefix, ndx) {
var id_regex = new RegExp("(" + prefix + "-(\\d+|__prefix__))");
var replacement = prefix + "-" + ndx;
if ($(el).prop("for")) {
$(el).prop("for", $(el).prop("for").replace(id_regex, replacement));
}
if (el.id) {
el.id = el.id.replace(id_regex, replacement);
}
if (el.name) {
el.name = el.name.replace(id_regex, replacement);
}
// @HACK(richard) needed for django trix
if ($(el).attr('input')) {
$(el).attr('input', $(el).attr('input').replace(id_regex, replacement));
}
};
I wonder if there's a way to modify the way this is implemented so it works with django's built-in javascript. If the "for" property is used instead of "input", that could make it work.
The editor doesn't work with new inlines in the admin that are created with javascript. If you press the "Add a new row" button, the editor shows up, but it doesn't update the hidden textarea. This happens, because the html is not updated correctly. The javascript produces something like this:
Notice the "
__prefix__" is still there.I was able to work around this by making my own copy of
static/admin/js/inlines.jsand adding a few lines:I wonder if there's a way to modify the way this is implemented so it works with django's built-in javascript. If the "for" property is used instead of "input", that could make it work.