2012-07-20 110 views
0

在我以前的文章之一,我收到了一些很好的建议,我决定使用富文本编辑器tiny_mce制作我的博客,但我有一个问题。我不能包含tiny_mce或包含它后,它不起作用。我设置了开发者如何指导你,但没有改变正常的textarea。我该怎么办?Tiny_mce编辑器没有显示codigniter

<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 


    <script type="text/javascript" src="<?php echo base_url(); ?>js/tiny_mce/tiny_mce.js"></script> 
    <script> 
     tinyMCE.init({ 
     // General options 
     mode : "textareas", 
     theme : "advanced", 
     plugins : "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,wordcount,advlist,autosave", 

     // 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,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft", 
     theme_advanced_toolbar_location : "top", 
     theme_advanced_toolbar_align : "left", 
     theme_advanced_statusbar_location : "bottom", 
     theme_advanced_resizing : true, 

     // Example content CSS (should be your site CSS) 
     content_css : "css/content.css", 

     // Drop lists for link/image/media/template dialogs 
     template_external_list_url : "lists/template_list.js", 
     external_link_list_url : "lists/link_list.js", 
     external_image_list_url : "lists/image_list.js", 
     media_external_list_url : "lists/media_list.js", 

     // Style formats 
     style_formats : [ 
      {title : 'Bold text', inline : 'b'}, 
      {title : 'Red text', inline : 'span', styles : {color : '#ff0000'}}, 
      {title : 'Red header', block : 'h1', styles : {color : '#ff0000'}}, 
      {title : 'Example 1', inline : 'span', classes : 'example1'}, 
      {title : 'Example 2', inline : 'span', classes : 'example2'}, 
      {title : 'Table styles'}, 
      {title : 'Table row 1', selector : 'tr', classes : 'tablerow1'} 
     ], 

     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'} 
     }, 

     // Replace values for the template plugin 
     template_replace_values : { 
      username : "Some User", 
      staffid : "991234" 
     } 
    }); 
     </script> 
     </head> 
<body> 
<form method="post" action="somepage"> 
<textarea name="content" style="width:100%;height: 400px;"> 
&lt;p&gt;This is &lt;strong&gt;my text&lt;/strong&gt; that I &lt;strong&gt;use&lt;/strong&gt; for my example.&lt;/p&gt; 
</textarea> 

</form> 
    </body> 


</html> 
+0

你如何包含tiny_mce.js(我在你的代码中看不到)?你会得到什么错误? – Thariama 2012-07-20 07:31:03

+0

@Thariama这只是一个复制粘贴错误,现在我编辑它。 – 2012-07-20 08:04:38

+0

你会得到什么错误? – Thariama 2012-07-20 08:20:21

回答

0

我刚刚将你的代码复制到一个平的html文件,它工作正常。我的猜测是tiny_mce.js的路径错误。

问题:当您查看页面的源代码时,tiny_mce.js文件的路径是否正确? base_url()js/tiny_mce/tiny_mce.js真的是你的js文件所在的位置吗?你可以在浏览器中打开site.com/js/tiny_mce/tiny_mce.js文件吗?

此外,有竞争的JavaScript文件?或者,您是否使用JQuery版本的tiny,而无需将JQuery预加载到您的视图中?

您是否在使用Firebug或Chrome开发人员工具时遇到麻烦?

+0

我改变了我的编辑器,现在使用ck编辑器。它的工作原理。感谢您的回复。 – 2012-07-21 06:40:28

0

在我的情况下,我很困惑,因为我在其他项目中使用tinymce没有问题。在下载了最新版本后,在tinymce.com提供的示例的插件列表中包含了moxiemanager,它阻止了输出。从列表中删除这个项目解决了这个问题。请参阅TinyMCE moxiemanager