2

我有这个问题:在我的网站中有带有tinymce的textarea,我可以看到所有textarea,但是当我在textarea中打开colorbox时,这不会继承tinymce属性。这是我打开颜色框的代码:

$("#edit_item"+val.iditem).colorbox({
   href: $(this).attr('href'),                     
   data: data,
   onComplete: function(){ setup_tiny(); }  
});

这是我的函数“setup_tiny”:

function setup_tiny(){
    tinyMCE.init({
      mode : "exact",
    elements : "description",        
        width : "40%",        
        height: "200",

        // General options        
        theme: "advanced",

        // Theme options
        theme_advanced_buttons1: "bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull",
        theme_advanced_buttons2: "bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image,cleanup,help,code",
        theme_advanced_buttons3: "hr,removeformat,separator,sub,sup,separator",
        theme_advanced_buttons4: "",

        theme_advanced_toolbar_location: "top",
        theme_advanced_toolbar_align: "left",
        theme_advanced_resizing: true
   });
}

我刚刚尝试过这种方式,加载彩盒后:

tinyMCE.execCommand('mceFocus', false, 'the_textareas_id_here');                    
tinyMCE.execCommand('mceRemoveControl', false, 'the_textareas_id_here');

但它也不起作用。我也尝试从这个站点'http://mktgdept.com/jquery-tinymce-plugin'导入tinymce插件,这也不起作用。

如何在彩盒中加载tinymce?谢谢

4

2 回答 2

3

我已经使用以下代码解决了我的问题:

function setup_tiny(textarea_name){      
    tinyMCE.init({
        mode : "exact",
        elements : textarea_name,                                

        // General options        
        theme: "advanced",

        // Theme options
        theme_advanced_buttons1: "bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull",
        theme_advanced_buttons2: "bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image,cleanup,help,code",
        theme_advanced_buttons3: "hr,removeformat,separator,sub,sup,separator",
        theme_advanced_buttons4: "",

        theme_advanced_toolbar_location: "top",
        theme_advanced_toolbar_align: "left",
        theme_advanced_resizing: true
   });
}
$("#edit_item"+val.iditem).colorbox({
    href: $(this).attr('href'),                     
    data: data,
    onComplete: function(){                            
        setup_tiny("new_description");
    }                
}); 

通过这种方式,我调用了我的函数“setup_tiny”,其中 id textarea 作为参数传递。

于 2012-12-05T13:50:04.730 回答
1

问题可能是您正在调用 $("#edit_item"+val.iditem)隐藏的 textarea 元素。Tinymce 不是文本区域!它是一个内容可编辑的 iframe。您可以尝试执行以下操作:

$(tinymce.get('description').getBody()).colorbox({
   href: $(this).attr('href'),                     
   data: data,
   onComplete: function(){ setup_tiny(); }  
});
于 2012-12-04T14:39:08.693 回答