Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It looks like some of the CSS classes and HTML structures used by Grappelli have changes since Almflm's solution was written. However, I was able to modify hir solution to work with Grappelli v2.4.7, and simplified the implementation in the process. </p> <p><strong>Setup</strong></p> <ol> <li>Override the relevant template by copying <code>/PATH/TO/grappelli/templates/admin/edit_inline/stacked.html</code> to <code>/PATH/TO/YOURMOD/templates/admin/edit_inline/</code></li> <li>In your site's <code>settings.py</code>, ensure that YOURMOD is <em>above</em> grappelli in <code>INSTALLED_APPS</code>. Otherwise, Django will continue using the Grappelli version of the template.</li> </ol> <p><strong>Code</strong></p> <p>Now you just need to make two changes to your copy of <code>stacked.html</code>. Find the block of javascript that begins:</p> <pre><code>$("#{{ inline_admin_formset.formset.prefix }}-group").grp_inline({ </code></pre> <p>...and make the following changes inside that block:</p> <ol> <li><p>Add an <code>onBeforeAdded</code> function like this (or modify the existing function if one exists, but I didn't have one):</p> <pre><code> onBeforeAdded:function(form) { // New inlines start as a hidden template with class grp-empty-form. // This contains a textarea, which TinyMCE converts correctly, but // something about the transformation from template to visible // form breaks TinyMCE, so we need to remove it from the template and // then re-add it after the transformation. // c.f. http://stackoverflow.com/questions/5738173/ if (tinyMCE != undefined) { django.jQuery('.grp-empty-form').find('textarea').each(function() { var tid = django.jQuery(this).attr("id"); tinyMCE.execCommand("mceRemoveControl",false,tid); }); } }, </code></pre></li> <li><p>Add the following to the <code>onAfterAdded</code> function (you should already have one, so be sure to modify the existing one rather than defining a new one!):</p> <pre><code> if (tinyMCE != undefined) { // re-initialise tinyMCE instances deselector = tinyMCE.settings.editor_deselector; django.jQuery(form).find('textarea:not(.'+deselector+')').each(function(k,v) { var tid = django.jQuery(this).attr('id'); tinyMCE.execCommand('mceAddControl', false, tid); }); } // This line is optional. It just ensures that the new inline appears // un-collapsed, even if inlines are collapsed by default django.jQuery(form).removeClass("grp-closed").addClass("grp-open"); </code></pre></li> </ol> <p>That's it!</p> <p><strong>EDIT</strong> Added the deselector to the <code>onAfterLoad</code> - ensures you can still define a deselector class in a tinymce config file, and inlines will conform to this.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload