TinyMce 使用 ASP.NET MVC 3 和 Razor View Engine - 加载但不显示
我有一个使用 TinyMce jQuery 插件的简单表单。当我加载页面时,TinyMce 应该用他的编辑器替换我的文本区域,但这并没有发生。查看生成的 html,我的文本区域在那里(可见性设置为隐藏),但 TinyMce 没有创建 iFrame 对象。 TinyMce 对象存在,但 activeEditor 为空。就好像我还没有初始化它,但我完全按照以下示例代码进行操作:
// 这是我加载脚本的位置
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery.tinymce.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/tiny_mce_jquery.js")"></script>
// 这是我的文本区域
<textarea id="tinymceId" name="content" class="tinymce" rows="1" cols="50" style="width:100%;" ></textarea>
// 这是我初始化它的脚本代码
$(document).ready(function () {
$('#tinymceId').tinymce({
doctype: '<!DOCTYPE html>',
editor_selector: "tinymce",
convert_urls: false,
mode: "textareas",
});
});
I have a simple form using the TinyMce jQuery plugin. When I load the page, TinyMce is supposed to replace my textarea with his editor, but this does not happen. Looking at the html generated, my textarea is there (visibility set to hidden) but no iFrame object was created by TinyMce. The TinyMce object exists, but the activeEditor is null. It is as if I have not initialized it, but I am following the sample code exactly as follows:
//here is where I load the scripts
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery.tinymce.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/tiny_mce_jquery.js")"></script>
// here is my text area
<textarea id="tinymceId" name="content" class="tinymce" rows="1" cols="50" style="width:100%;" ></textarea>
//and here is my script code where I initialize it
$(document).ready(function () {
$('#tinymceId').tinymce({
doctype: '<!DOCTYPE html>',
editor_selector: "tinymce",
convert_urls: false,
mode: "textareas",
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嗯,现在最著名的变酷方式就是使用 Nuget。
我为 TinyMCE 编写了一些部分视图模板。 (当 TinyMCE 更新时,我也会将其推送到提要)
以下文章将引导您完成该过程:
TinyMCE HTML 文本编辑器 & ASP.NET MVC - 使用 Nuget 使设置变得简单
Well, the most famous way of being cool nowadays is to use Nuget.
I have written some partial view templates for TinyMCE. (I also push TinyMCE to the feed when it is being updated)
Following article will walk you through for the process :
TinyMCE HTML Text Editior & ASP.NET MVC - Setting It Up Has Become Easy With Nuget
如果注释掉设置
editor_selector: "tinymce",
会有什么区别吗?另一件事要提的是:
我不是 jquery 构建(tiny_mce_jquery.js/jquery.tinymce.js)的朋友,有几个原因(例如它很慢,......)。使用tiny_mce.js 代替有什么区别吗?您也可以在页面上加载常规 jquery.js - 这是高效且运行良好的。
Does it make any difference if you comment out the setting
editor_selector: "tinymce",
?Another thing to mention:
I am not a friend of the jquery build (tiny_mce_jquery.js/jquery.tinymce.js) for several reasons (it is slow for example, ...). Does it make any difference to use the tiny_mce.js instead? You may load the regular jquery.js on the page too - that is efficient and works well.