Changes between Initial Version and Version 1 of AddDojoEditor


Ignore:
Timestamp:
May 31, 2006, 7:53:31 AM (18 years ago)
Author:
anonymous
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AddDojoEditor

    v1 v1  
     1Download [http://www.dojotoolkit.org Dojo] (kitchen sink) and save it as /media/dojo/...
     2
     3Save the following script as AddRichTextEditing.js into /media/js/admin/
     4
     5{{{
     6document.write('<script type="text/javascript" src="/media/dojo/dojo.js"></script>');
     7document.write('<script type="text/javascript">dojo.require("dojo.widget.Editor2");</script>');
     8
     9var AddEditor = {
     10        init: function() {
     11                var helptext = document.getElementsByTagName('p');
     12                for (var i = 0, ht; ht = helptext[i]; i++) {
     13                                if (ht.firstChild.data == "Rich Text Editing.") {
     14                                    ht.previousSibling.previousSibling.setAttribute("dojoType", "Editor2");
     15                                }
     16                }
     17        },
     18}
     19
     20addEvent(window, 'load', AddEditor.init);
     21}}}
     22
     23This script looks for the help text "Rich Text Editing." and replaces the textarea before with the Dojo-Editor.
     24
     25Define your model like this:
     26
     27{{{
     28body = models.TextField('Body', help_text='Rich Text Editing.', blank=True, null=True)
     29...
     30class Admin:
     31     js = ['js/admin/AddRichTextEditing.js']
     32}}}
     33
     34that´s it.
     35
     36result could look like
     37
     38[http://www.vonautomatisch.at/django/dojoeditor.jpg Screenshot (Preview)]
Back to Top