Changes between Version 12 and Version 13 of AddWYSIWYGEditor


Ignore:
Timestamp:
10/30/2007 02:16:19 PM (8 years ago)
Author:
Ludvig Ericson <ludvig.ericson@…>
Comment:

Previous way didn't work at all.

Legend:

Unmodified
Added
Removed
Modified
  • AddWYSIWYGEditor

    v12 v13  
    7373
    7474=== With newforms-admin ===
    75 '''With [wiki:NewformsAdminBranch newforms-admin]''', please note that you need to override the {{{__init___}}} method in [source:django/branches/newforms-admin/django/contrib/admin/options.py your model's option class] and add TinyMCE's JavaScripts to {{{self.media}}}, which is a property.
     75'''With [wiki:NewformsAdminBranch newforms-admin]''', you have to use black magic, at the time of writing.
     76
     77If you look at [source:django/branches/newforms-admin/django/contrib/admin/options.py the AdminOptions class], you'll note that there's a {{media}} property, which generates a
     78new {{Media}} object each time you access the attribute. To get by that, we need to remake this property and "inject" our own JavaScripts.
    7679
    7780{{{
    7881#!python
    7982class MyAdminOpts(admin.ModelOptions):
    80     # Fully emulate the super function, even returning whatever from __init__,
    81     # in case there'll be future hackeries on the internal API.
    82     def __init__(self, *a, **kw):
    83         r = super(MyAdminOpts, self).__init__(*a, **kw)
    84         self.media.add_js(("http://path/to/TinyMCE/files", "http://more/paths"))
    85         return r
     83     def _media(self):
     84         media = super(MyAdminOpts, self)._media()
     85         media.add_js([
     86             "http://path/to/tiny_mce.js",
     87             "http://path/to/settings/"])
     88         return media
     89     media = property(_media)
    8690}}}
    87 
    88 ''[ed: I haven't tried this yet, so you may have to do some own researh.]''
    89 ----
    9091
    9192=== Using TinyMCE with flatpages ===
Back to Top