1

在使用 jQuery 版本的 TinyMCE 时,jQuery 和 TinyMCE 的交互方式存在问题,该问题已多次报告并解决。据我了解,它涉及 TinyMCE 对 jQuery attr() 函数的重新定义。

结果是当页面上没有使用 TinyMCE 时,下面的 while 将返回属性值:

var junk = $(this).attr('someAttribute');

当使用 TinyMCE 时,会返回一个对象。

我在使用 jQuery 1.7.2 和 TinyMCE 3.5.2 时遇到了这个问题。

还有其他人遇到这个吗?如果是这样,是否有解决方法?

4

2 回答 2

3

TinyMCE jquery 的插件会破坏 jQuery 的attr方法 (jQuery>=1.7.2.)。这是在 TinyMCE 3.5b3 中修复的。

供您参考,这里是一个报告的TinyMCE 错误 #5136和一个修复

于 2012-09-26T02:37:24.787 回答
0

我正在发布这个问题的答案,但如果有人有不同的解决方案,我仍然很想听听。

基本上,我接受了 Thariama 的建议并停止使用 tinyMCE 的 jQuery 构建。相反,我做了以下事情:

    tinyMCE.init({
        mode: "specific_textareas",
        editor_selector: "tinymce",
        script_url: '@Url.Content("~/Scripts/tinymce/tiny_mce.js")',
        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",
        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",
        theme_advanced_toolbar_location: "top",
        theme_advanced_toolbar_align: "left",
        theme_advanced_statusbar_location: "bottom",
        theme_advanced_resizing: true,
        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",
        convert_urls: 0, // default 1
        content_css: '@Url.Content("~/Content/tinymce.css")'
    });

这是基于我在 StackOverflow 其他地方找到的建议解决方案。

仅供从 jQuery 版本的 tinyMCE 转换的其他人参考:您需要记住将 mode: 和 editor_selector: 参数添加到您之前使用的参数列表中。如果不这样做,您将获得将每个 textarea 控件转换为 tinyMCE 编辑器的默认行为。

您还需要在页面标题中包含 tinyMCE 库。在我的应用程序中,如下所示:

<script src="@Url.Content("~/Scripts/tinymce/tiny_mce.js")" type="text/javascript"></script>

享受!

于 2012-06-13T20:46:37.293 回答