Login

FCKEditor replace all vLargeTextField in admin

Author:
aronchi
Posted:
October 24, 2008
Language:
JavaScript
Version:
Not specified
Score:
0 (after 0 ratings)

If you want to add an fckeditor for every vLargeTextField (the input class used by models.TextField) you can use this javascript.

you can load that in all admin pages overriding templates/admin/base_site.html with this:

{% extends "admin/base.html" %} {% load i18n %}

{% block title %}{{ title }} | {% trans "Administrative Area" %}{% endblock %}

{% block branding %} <h1 id="site-name">{% trans "Administrative Area" %}</h1> {% endblock %}

{% block nav-global %}{% endblock %}

{% block extrahead %}{{ block.super }} <script src="{{media_url}}js/jquery.js" type="text/javascript"></script> <script src="{{media_url}}fckeditor/fckeditor.js" type="text/javascript"></script> <script src="{{media_url}}fckeditor/custom/vTextField.js" type="text/javascript"></script> {% endblock %}

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
window.onload = function () {
	var allPageTags = document.getElementsByTagName("textarea");
	var editors = new Array();
	for (i = 0; i < allPageTags.length; i++) {
		if (allPageTags[i].className == "vLargeTextField") {
			var oFCKeditor = new FCKeditor(allPageTags[i].id);
			oFCKeditor.Config["CustomConfigurationsPath"] = "/static/fckeditor/custom/myconfig.js";
			oFCKeditor.BasePath = "/static/fckeditor/";
			oFCKeditor.Height = "400";
			oFCKeditor.ReplaceTextarea();
			editors.push(oFCKeditor);
		}
	}
};

More like this

  1. Django Collapsed Stacked Inlines by applecat 3 years ago
  2. Django Collapsed Stacked Inlines by mkarajohn 5 years, 2 months ago
  3. Dynamically adding forms to a formset. OOP version. by halfnibble 10 years, 10 months ago
  4. Convert multiple select for m2m to multiple checkboxes in django admin form by abidibo 12 years, 11 months ago
  5. Django admin inline ordering - javascript only implementation by ojhilt 13 years, 3 months ago

Comments

Please login first before commenting.