2012-12-03 129 views
2

我有这个问题:在我的网站有tinymce textareas和我可以看到所有textarea的权利,但是当我打开textarea内的colorbox,这不会继承tinymce属性。 这是我的代码以打开颜色框:加载tinybox到colorbox

$("#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? 谢谢

+0

你能描述一下colorbox的功能吗?你能提供一个像锡琴小提琴一样的现场实例吗? – Thariama

+0

[Here](http://www.tinymce.com/tryit/full.php)你能找到一个tinymce的例子。在我的网站中,只有当我在colorbox中的textarea上加载这个插件时才起作用。 – PapaSmurf

+1

不,我没有想要一个随机的Tinymce编辑器的例子,我想要一个你的用例的实例。我建议你在tinymce小提琴上创建一个小提琴(http://fiddle.tinymce.com/)。使用这个我能够发挥代码和找到解决方案 – Thariama

回答

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的。

+1

+1分享解决方案 – Thariama

1

问题可能是您正在隐藏的textarea元素上调用 $("#edit_item"+val.iditem)。 Tinymce不是textarea!这是一个可以满足的iframe。您可以尝试做如下:

$(tinymce.get('description').getBody()).colorbox({ 
    href: $(this).attr('href'),      
    data: data, 
    onComplete: function(){ setup_tiny(); } 
}); 
+0

我已经尝试过,但它doesn'工作。 – PapaSmurf

+0

colorbox通常会做什么?也许你需要地址另一个html元素 – Thariama

+0

我已经发布了解决方案。 – PapaSmurf