我有一个非常奇怪的问题,
首先:这是我的小init:
function recargar_tiny(){
// General options
tinyMCE.init({
// General options
mode : "textareas",
theme : "advanced",
plugins : "spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
// Theme options
theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
// Skin options
skin : "o2k7",
skin_variant : "silver",
// Example content CSS (should be your site CSS)
content_css : "css/style.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "js/template_list.js",
external_link_list_url : "js/link_list.js",
external_image_list_url : "js/image_list.js",
media_external_list_url : "js/media_list.js",
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
}
我所做的是通过ajax加载表单,然后调用tinymce init
这是结果: Firebug没有任何错误......:?
请注意那里应该有一个textarea而且没有......:?
PS:但是如果我不是通过ajax做到这一点,如果我这样做,那么它工作得很好......这让我很生气,你能看到什么吗?EDIT2
这是我使用tiny init的ajax调用
function editar_item(id, tipo){
// where id and tipo are int ID's
$("#router").load('/includes/router.php?que=editar_item&id='+id+'&tipo='+tipo,{},function(){
// where <textarea id="texto" name = "texto">
tinyMCE.execCommand('mceAddControl', false, 'texto');
});
}
现在它不是删除textarea但它没有加载wyswyg ..:?
有什么想法吗?
-EDIT3 -
如果我在jquery ajax调用之后这样做:
tinyMCE.init({
mode : "textareas",
theme : "advanced",
plugins : "inlinepopups",
media_strict: false,
// Theme options
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,forecolor,image,link,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,|,removeformat,|,bullist,numlist,|,outdent,indent",
heme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_buttons4 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "center",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
editor_deselector : "no_tiny",
// Example content CSS (should be your site CSS)
content_css : "/js/tinymce/examples/css/content.css",
// Style formats
style_formats : [
{title : 'Bold text', inline : 'b'},
{title : 'Blue text', inline : 'span', styles : {color : '#006'}},
{title : 'Blue header', block : 'h1', styles : {color : '#006'}},
{title : 'Codigo fuente', inline : 'code', classes : 'prettyprint', exact: true}
],
formats : {
alignleft : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'left'},
aligncenter : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'center'},
alignright : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'right'},
alignfull : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'full'},
bold : {inline : 'span', 'classes' : 'bold'},
italic : {inline : 'span', 'classes' : 'italic'},
underline : {inline : 'span', 'classes' : 'underline', exact : true},
strikethrough : {inline : 'del'},
customformat : {inline : 'span', styles : {color : '#00ff00', fontSize : '20px'}, attributes : {title : 'My custom format'}}
}
});
然后它有效!但不是我需要的功能已启用.... :(
谢谢!
答案 0 :(得分:0)
您应该在init
中使用“exact”模式mode: 'exact',
然后当ajaxrequest结束时,你打电话
tinyMCE.execCommand('mceAddControl', false, editorid); //use the textarea id as editor_id here