Arbie Samong
Arbie Samong

Reputation: 1205

TinyMCE is not showing up no matter what

Now this is not django-tinymce, as I don't need it on my other pages. Just this one page, and it's not showing up it's making my head hurt. The tiny_mce.js is correctly seen when checking in Firebug, and no javascript errors on console whatsoever. I even tried with mode: 'exact' and element: 'id_description' but nada.

{% block content %}
<script type="text/javascript" src="/static/js/tiny_mce.js"></script>
<script type="text/javascript">
  tinyMCE.init({
      mode : "textareas",
      theme : "simple"
  });
</script>  

<form class="myform" action="{{ form_action }}" method="post">{% csrf_token %}
    <ul>        
        <li><label for="id_description">Description:</label>
            <textarea name="description" cols="40" rows="10" id="id_description"></textarea>
        </li>        
    </ul>
    <input type="submit" value="Submit" />
</form>

{% endblock %}

Upvotes: 4

Views: 5268

Answers (3)

OrahSoft
OrahSoft

Reputation: 803

You need to specify on init which control to make tinyMCE.

<script type="text/javascript">    
  tinyMCE.init({        
    mode : "textareas",
    elements: "id_description",    
    theme : "simple"   
  });  
</script>`

Upvotes: 0

Arbie Samong
Arbie Samong

Reputation: 1205

I got it to work. I just need to copy the whole tiny_mce/ folder (I only placed the tiny_mce.js script) and then updated my script tag accordingly:

<script type="text/javascript" src="/static/js/tiny_mce/tiny_mce.js"></script>

I figured this out because the runserver screen showed up some pretty suspicious error messages:

[07/Mar/2011 21:31:16] "GET /static/js/themes/simple/editor_template.js HTTP/1.1" 302 0
Traceback (most recent call last):
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/servers/basehttp.py", line 280, in run
    self.result = application(self.environ, self.start_response)
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/servers/basehttp.py", line 674, in __call__
    return self.application(environ, start_response)
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/handlers/wsgi.py", line 245, in __call__
    response = middleware_method(request, response)
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/middleware/common.py", line 97, in process_response
    % (referer, request.get_full_path(), ua, ip))
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/mail/__init__.py", line 101, in mail_managers
    connection=connection).send(fail_silently=fail_silently)
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/mail/message.py", line 175, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/mail/backends/smtp.py", line 78, in send_messages
    new_conn_created = self.open()
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/mail/backends/smtp.py", line 41, in open
    local_hostname=DNS_NAME.get_fqdn())
  File "/usr/lib/python2.6/smtplib.py", line 239, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib/python2.6/smtplib.py", line 295, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib/python2.6/smtplib.py", line 273, in _get_socket
    return socket.create_connection((port, host), timeout)
  File "/usr/lib/python2.6/socket.py", line 514, in create_connection
    raise error, msg
error: [Errno 111] Connection refused
[07/Mar/2011 21:31:16] "GET /static/js/langs/en.js/ HTTP/1.1" 500 2102
Traceback (most recent call last):
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/servers/basehttp.py", line 280, in run
    self.result = application(self.environ, self.start_response)
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/servers/basehttp.py", line 674, in __call__
    return self.application(environ, start_response)
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/handlers/wsgi.py", line 245, in __call__
    response = middleware_method(request, response)
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/middleware/common.py", line 97, in process_response
    % (referer, request.get_full_path(), ua, ip))
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/mail/__init__.py", line 101, in mail_managers
    connection=connection).send(fail_silently=fail_silently)
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/mail/message.py", line 175, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/mail/backends/smtp.py", line 78, in send_messages
    new_conn_created = self.open()
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/mail/backends/smtp.py", line 41, in open
    local_hostname=DNS_NAME.get_fqdn())
  File "/usr/lib/python2.6/smtplib.py", line 239, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib/python2.6/smtplib.py", line 295, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib/python2.6/smtplib.py", line 273, in _get_socket
    return socket.create_connection((port, host), timeout)
  File "/usr/lib/python2.6/socket.py", line 514, in create_connection
    raise error, msg
error: [Errno 111] Connection refused
[07/Mar/2011 21:31:16] "GET /static/js/themes/simple/editor_template.js/ HTTP/1.1" 500 2102

Upvotes: 2

Daniel Roseman
Daniel Roseman

Reputation: 599610

I haven't touched this for years, but I remember I had trouble getting the textareas mode to work. Instead, I had to use exact mode and specify the IDs of the specific form element:

{ mode : "exact",
  elements : "id_description" }

Upvotes: 3

Related Questions