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

4

5 回答 5

2

我遇到了同样的问题,并在页面加载时通过加载对话框修复。例如:

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

当你想打开对话框时:

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

希望这有帮助!

于 2013-10-16T10:07:07.260 回答
1

激活 TinyMCE 时需要 settimeout,因为对话框初始化时需要等待时间。

例如 :

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

如果 tinymce 已加载但您无法输入(如禁用)。您需要为 setTimeout 设置更多时间。

对不起,我的英文皮肤不好

于 2013-05-29T16:24:34.683 回答
1

我也遇到了同样的错误......我的第一个代码

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

在我删除选项之后

show: "clip",

像这样

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

tinyMCE 之后运行良好

于 2014-02-26T00:35:32.587 回答
1

您应该在加载对话框后加载编辑器。你可以做的是:

  1. 使用 $editor->display 方法像现在一样加载编辑器
  2. 在打开 jquery ui 对话框之前,分离编辑器
  3. 显示 UI 对话框并再次加载编辑器,稍有延迟,以便编辑器在对话框后加载。

这是一个示例代码

触发对话框打开后使用此代码

if ((tinyMCE != undefined) && (tinyMCE.activeEditor != undefined)){
  tinyMCE.activeEditor.remove();
  setTimeout(function(){
    tinyMCE.execCommand('mceAddControl', false, 'commentz');
  },500);
}
于 2013-05-27T11:01:51.313 回答
0

Nagarjun 回答的一个小修正使脚本对我有用:

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

即:我需要在打开对话框并启动超时之前删除 tinyMCE

于 2015-08-28T17:20:38.203 回答