| | 68 | == Alternative version == |
| | 69 | |
| | 70 | Another way to do this is to use the fieldset support in the Admin interface, and set the CSS class for the fieldset |
| | 71 | to `wysiwyg`; see http://www.djangoproject.com/documentation/model_api/#classes for more details on how to do this. |
| | 72 | Then use this version of `AddRichTextEditing.js`: |
| | 73 | |
| | 74 | {{{ |
| | 75 | document.write('<script type="text/javascript" src="/media/dojo/dojo.js"></script>'); |
| | 76 | document.write('<script type="text/javascript">dojo.require("dojo.widget.Editor2");</script>'); |
| | 77 | |
| | 78 | var AddEditor = { |
| | 79 | init: function() { |
| | 80 | var fieldsets = document.getElementsByTagName('fieldset'); |
| | 81 | for (var i = 0, fs; fs = fieldsets[i]; i++) { |
| | 82 | var classes = fs.className || fs.getAttribute("class"); |
| | 83 | if ( (classes) && (classes.indexOf) && (classes.indexOf("wysiwyg") != -1) ) { |
| | 84 | var textareas = fs.getElementsByTagName('textarea'); |
| | 85 | for (var j = 0, ta; ta = textareas[j]; j++) { |
| | 86 | ta.setAttribute("dojoType", "Editor2"); |
| | 87 | } |
| | 88 | } |
| | 89 | } |
| | 90 | }, |
| | 91 | } |
| | 92 | |
| | 93 | addEvent(window, 'load', AddEditor.init); |
| | 94 | }}} |
| | 95 | |
| | 96 | This looks for all `fieldset`s with a `class` of `wysiwyg`, and then finds any contained `textarea`s and gives them |
| | 97 | a `dojoType="Editor2"` attribute. The value of `help_text` is unimportant and shows up as normal. |