2013-07-02 191 views
1

我目前使用tinyMCE并使用oninit函数将自定义页脚添加到messageBody。在编辑器中获取页脚没有任何问题,但当用户添加导致页面刷新的附件时,我遇到了问题。除了页脚以外的所有内容都将从编辑器中删除。 (代码正在做它应该做的事情!)有没有办法让tinyMCE在页面刷新时不能重新启动,或者我可以采用不同的路由?代码如下:在页面刷新时不启动tinymce

<script type="text/javascript"> 
    <!-- Intiate tinyMCE --> 
    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", 
    "apply_source_formatting" : true, 
    "paste_auto_cleanup_on_paste" : false, 
    "paste_retain_style_properties" : "all", 
    //The below two lines to fix enter problem after a pastes is done by the user 
    "force_br_newlines" : true, 
    "force_p_newlines" : false, 

    // Theme options 
    theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,cut,copy,paste,pastetext,|,search,replace,|,bullist,numlist,|,outdent,indent,|,formatselect,fontselect,fontsizeselect", 
    theme_advanced_buttons2 : "undo,redo,|,link,unlink,|,insertdate,inserttime,preview,|,forecolor,backcolor,|,tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,advhr,|,ltr,rtl,|,fullscreen,|,wordcount", 

    //Calling a new CSS file to set Default Font and Text size 
    content_css : "/js/tiny_mce/themes/advanced/skins/default/custom.css" + new Date().getTime(), 
    theme_advanced_toolbar_location : "top", 
    theme_advanced_toolbar_align : "left", 
    theme_advanced_statusbar_location : "bottom", 
    theme_advanced_resizing : true, 

    oninit: function(){ 
     tinyMCE.get('messageBody').setContent('<br><br><p>This message was generated by the Tool <br> If you are experiencing any issues with the Tool, please contact us <a href="mailto:[email protected]">here</a> <br><a href="https://www.google.com">The Tool</a></p>'); 
    } 



    }); 
    </script> 

回答

1

如果你有用户上传使用隐藏的iframe的附件,因为那么你的主页与tinyMCE不会被刷新。你目前是否在使用通用文件上传?如果你想改变使用一个打包的,我已经使用plupload一段时间,它是一个非常有用的文件上传工具。

+0

这可能是一个选项。真的不想把页面放在框架中,但看着它,这可能是我唯一的方法。谢谢 –

+0

不要把你的页面放在iframe中,只需要一个iframe来完成上传,这样你的tinymce主页就不会被刷新。有很多通过iframe简单上传的例子。祝你好运 :) – jjay225