1

I am using the joomla built in function to create a tinyMCE editor on a page within a jQuery dialog box. However, the dialog box appears and the tinyMCE editor is like its in read only mode.

This is the php built in function that echos out the editor:

<div id="PhoneCallCard" title="Phone Call Card" style="display:none;">      
    <?php
      $editor = JFactory::getEditor();                                                                                          
      echo $editor->display('commentz', $this->content, '600', '100', '60', '20', false);      
    ?>
</div>

This is my jQuery implementation of opening that dialog box:

jQuery("#PhoneCallCard").dialog({
            height:500,
            width:800,
            modal: true,
            close: function(ev, ui){                                                
              jQuery('#tablepanelfightclubrequests .trSelected').removeClass('trSelected');                         
              },
            open:function({ //Everything I tried to activate the tinyMCE
           //tinyMCE.activeEditor.getBody().setAttribute('contenteditable', false);
           //tinyMCE.execCommand('mceRemoveControl',false,'commentz');
           //tinyMCE.execCommand('mceAddControl',false,'commentz');
           //tinyMCE.execCommand('mceFocus', false, 'commentz');
            }});

I also found similar problem here Why can't I type in TinyMCE in my jQueryUI modal dialog? and here TinyMCE and JQuery dialog: TinyMCE read only when modal:true in the Dialog but both can't solve my problem

Community
  • 1
  • 1
themhz
  • 8,335
  • 21
  • 84
  • 109

5 Answers5

2

I got same problem and fix by load dialog when page load. For example:

jQuery(function() {
jQuery( "#dialog_desc" ).dialog({
    modal: true,
    width: 600,
    height:500,
    autoOpen: false,
});
}

when you want to open dialog:

    jQuery( "#dialog_desc" ).dialog( "open" );

Hope this help!

Truong Pham
  • 177
  • 2
  • 18
1

You should load the editor after the dialog is loaded. What you can do is:

  1. Load the editor as you are doing now using $editor->display method
  2. Before opening the jquery ui dialog, detach the editor
  3. Display UI dialog and load editor again with slight time delay so that editor loads after dialog.

here is a sample code

use this code after the dialog open is triggered

if ((tinyMCE != undefined) && (tinyMCE.activeEditor != undefined)){
  tinyMCE.activeEditor.remove();
  setTimeout(function(){
    tinyMCE.execCommand('mceAddControl', false, 'commentz');
  },500);
}
Nagarjun
  • 2,346
  • 19
  • 28
1

You need settimeout when active TinyMCE, because, it need time waiting when dialog init.

for example :

$("#PositionShowDialog").dialog({
modal: true,
open: setTimeout('Change_TextareaToTinyMCE_OnPopup("#elementId");', 1000),
width: width,
......

If tinymce is loaded but you cannot type in it (like disabled) . You need set more time to setTimeout .

Sorry, my english skin not good

VirtualTroll
  • 3,077
  • 1
  • 30
  • 47
1

i was get same error like that too... my first code

$( "#f_edit_gallery" ).dialog({
autoOpen: false,
resizable: true,
show: "clip",
height:450,
width:850,
modal: true
});

after i delete option

show: "clip",

be like this

$( "#f_edit_gallery" ).dialog({
    autoOpen: false,
    resizable: true,
    height:450,
    width:850,
    modal: true
    });

tinyMCE run well after that

Artron
  • 256
  • 1
  • 4
  • 13
0

A small correction from the answer of Nagarjun makes the script work for me :

if ((tinyMCE != undefined) && (tinyMCE.activeEditor != undefined)){  
  tinyMCE.activeEditor.remove();  
  $("#dialogId").dialog('open');  
  setTimeout(function(){  
    tinyMCE.execCommand('mceAddControl', false, 'commentz');  
  },500);  
}  

ie : I need to remove tinyMCE before open the dialog and launch the timeout

Sami Kuhmonen
  • 30,146
  • 9
  • 61
  • 74