5

我使用的是 Rails 3.2.3,当 TinyMCE 在生产中加载时,我得到四个 404:

"NetworkError: 404 Not Found - http://[my-domain]/[current-path]//langs/en.js"
"NetworkError: 404 Not Found - http://[my-domain]/[current-path]//plugins/fullscreen/editor_plugin.js"
"NetworkError: 404 Not Found - http://[my-domain]/[current-path]//themes/advanced/editor_template.js"
"NetworkError: 404 Not Found - http://[my-domain]/[current-path]//plugins/media/editor_plugin.js"

也许这些文件是从 tiny_mce.js 异步调用的,因为它们没有在我的源代码中列出。我的 js 看起来像这样:

tinyMCE.init({
    theme: "advanced",
    mode: "textareas",
    plugins: "fullscreen, media",
    height: 300,
    relative_urls :true,
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,search,replace,|,bullist,numlist,|,outdent,indent,|undo,redo,|,link,unlink,anchor,image,cleanup,code,|,insertdate,inserttime,preview,hr,removeformat,visualaid,|,sub,sup,|,fullscreen,spellchecker",
    theme_advanced_buttons2 : "styleselect,formatselect,imageListBox,media",
    theme_advanced_buttons3 : "",
    editor_selector : "mceEditor",
    extended_valid_elements : "form[action|accept|accept-charset|enctype|method|name|onsubmit|id|name]",
    convert_urls : false,
    remove_script_host : false
});

function toggleTinyMCE(id) {
    if (!tinyMCE.get(id))
        tinyMCE.execCommand('mceAddControl', false, id);
    else
        tinyMCE.execCommand('mceRemoveControl', false, id);
}

我所有的 TinyMCE 文件都在目录 app/assets/javascripts/tiny_mce 中,所以我尝试将document_base_url和添加base_url到我的 init 参数中,但无论我设置什么,当我在 firebug 中检查 TinyMCE 时,我发现它们的值没有更改为我输入的内容。

我知道 kete 的 Rails 插件适用于 tinyMCE,但它的 README声明不建议将它用于 Rails >= 3.1

4

2 回答 2

0

I am not sure if this will help you, but you can give it a try. Here is the section about relative and absolute urls of the tinymce FAQ: http://www.tinymce.com/wiki.php/TinyMCE_FAQ#Paths.2FURLs_are_incorrect.2C_I_want_absolute.2Frelative_URLs.3F

于 2012-07-17T15:22:26.597 回答
0

您不需要更改 document_base_url。您可以将tinymce 直接添加到页面。

<script type="text/javascript" src="/assets/vendor/tiny_mce/tiny_mce.js"></script>

并且 make shure 所有来自 tinymce 的文件都通过添加到 config/application.rb 来编译资产管道

config.assets.precompile << 'vendor/tiny_mce/*'
于 2013-10-04T12:54:40.247 回答