TinyMCE 未定义 Jquery

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16907580/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 18:01:32  来源:igfitidea点击:

TinyMCE is not defined Jquery

jquerytinymce

提问by gustavo

Have been working on this error for 2 days and cannot get TinyMCE to work. I am using the jquery version of TinyMCE. Below is my HTML code with a form that contains a textarea. I use Google Inspect Element and under the console tab i get the following error: "Uncaught ReferenceError: tinymce is not defined". Any help would be appreciated.

已经解决这个错误 2 天了,但无法让 TinyMCE 工作。我正在使用 TinyMCE 的 jquery 版本。下面是我的 HTML 代码,其中包含一个包含 textarea 的表单。我使用 Google Inspect Element,在控制台选项卡下出现以下错误:“未捕获的 ReferenceError:tinymce 未定义”。任何帮助,将不胜感激。

<form id="add_update_form" action="" method="POST" title="Add Blog">

<p class="feedback"></p>

<!-- <label>Created:</label>
<input type="text" name="created"> -->

<label>Title:</label>
<input type="text" name="title" class="input-block-level">

<label>Content:</label>
<textarea width="100%" rows="10" cols="10" name="content" class="input-block-level"></textarea>

<div class="clear"></div>

</form>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"    type="text/javascript"></script>
<script src="<?php echo base_url();?>js/portal/tinymce/jquery.tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({
selector: "textarea",
plugins: [
    "advlist autolink lists link image charmap print preview anchor",
    "searchreplace visualblocks code fullscreen",
    "insertdatetime media table contextmenu paste moxiemanager"
],
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
});
</script>

采纳答案by Jasen

As you are using the jquery version you'll need to set it up like a jquery plugin

当您使用 jquery 版本时,您需要像 jquery 插件一样设置它

$(function() {
   $('textarea.tinymce').tinymce({
    ...
   });
});

http://www.tinymce.com/tryit/3_x/jquery_plugin.php

http://www.tinymce.com/tryit/3_x/jquery_plugin.php

回答by Rafal Gradziel

I looked at this page: http://www.tinymce.com/tryit/3_x/jquery_plugin.phpand clicked tab "View source" and noticed something.

我查看了此页面:http: //www.tinymce.com/tryit/3_x/jquery_plugin.php并单击“查看源代码”选项卡并注意到一些内容。

If you are using TinyMCE as jQuery plugin, there is additional parameter required script_url, so your code should look like this:

如果您使用 TinyMCE 作为 jQuery 插件,则需要额外的参数script_url,因此您的代码应如下所示:

$('textarea.tinymce').tinymce({
   script_url: 'js/portal/tinymce/tinymce.min.js',
...

Other solution is to use non-jQuery version:

其他解决方案是使用非 jQuery 版本:

<script src="<?php echo base_url();?>js/portal/tinymce/tinymce.min.js"></script>

and then use old method to init the TinyMCE (as in your initial code):

然后使用旧方法初始化 TinyMCE(如在您的初始代码中):

tinymce.init({
    selector: "textarea",
...

回答by basarat

It seems that TinyMCE js file is not loaded. Instead of:

似乎未加载 TinyMCE js 文件。代替:

<script src="<?php echo base_url();?>js/portal/tinymce/jquery.tinymce.min.js"></script>

Try the following:

请尝试以下操作:

<script src="//cdn.jsdelivr.net/tinymce/4.0b2/jquery/jquery.tinymce.min.js"    type="text/javascript"></script>