1

I am using Joomla! 1.5.26 and JCE 2.2.0.

I need to change the status of the JCE (disable/enable) using javascript. If disabled, then the editor is in readonly mode and the background is set to opacity 1.

When a user clicks on the edit/save button, the JCE should be enabled/disabled.

I found this links: http://www.tinymce.com/tryit/read_only_mode.php

I also found how I can disable the content (cross-browsers):

tinymce.get('editorID').getBody().setAttribute('contenteditable', 'false');

However, this code doesn't work:

J('#editorID').css({opacity:1});
tinymce.get('editorID').getDoc().designMode = 'Off';

How can I change the JCE background opacity from javascript?

Will it be possible to set the readonly mode by javascript?

mickmackusa
  • 43,625
  • 12
  • 83
  • 136
Daviddd
  • 761
  • 2
  • 12
  • 37

1 Answers1

0

To apply this setting correctly you have to insert the real tinymce id you can get a console using tinymce.activeEditor.id.

So you may use

var editor_id = tinymce.activeEditor.id;
tinymce.get(editor_id).getBody().setAttribute('contenteditable', 'false');
Thariama
  • 50,002
  • 13
  • 138
  • 166
  • Thanks for the prompt reply! I checked (using chrome latest version) This code works: var editor_id = tinymce.activeEditor.id; tinymce.get(editor_id).getBody().setAttribute('contenteditable', 'false'); Mine too: tinymce.get('editorID').getBody().setAttribute('contenteditable', 'false'); Doesn't work anyway: tinymce.get(editor_id).getDoc().designMode = 'Off'; J('#editorID').css({opacity:1}); I would like to add the opacity background, how? – Daviddd Jun 26 '12 at 09:28
  • that would be another question (i suggest you open one) – Thariama Jun 26 '12 at 10:26
  • I had 2 questions :-) The first one is ok, but not the second one: How can I change the JCE/(TinyMCE) opacity background from javascript? – Daviddd Jun 26 '12 at 11:59
  • this should do it: $('iframe#'+tinymce.activeEditor.id+'_ifr').attr('allowtransparency',true); . other attributes may be set to the iframe analog – Thariama Jun 26 '12 at 12:54
  • In the end...this is working: $('#editorID_parent').fadeTo(0, 0.5); jQuery fadeTo is a cross-browser function. You helped me to find the solution, thanks! – Daviddd Jun 26 '12 at 13:20