Ajax Firefox和TinyMCE 3.4.9韩元';我们不能在一起玩得很好

Ajax Firefox和TinyMCE 3.4.9韩元';我们不能在一起玩得很好,ajax,firefox,tinymce,jquery-dialog,Ajax,Firefox,Tinymce,Jquery Dialog,我已经向tinyMCE的人提交了一个bug,但我希望其他人已经遇到了这个问题,并且有一个合适的解决方法 情况如下: 我有一个带有tinyMCE控件的表单,我将它加载到jquery对话框中。第一次的时候效果很好,然后他们关上它,打开一个新的。与tinyMCE控件的任何交互都会产生: "Node cannot be used in a document other than the one in which it was created" 它也不会用应该预先填充的文本填充控件 在jquery对话

我已经向tinyMCE的人提交了一个bug,但我希望其他人已经遇到了这个问题,并且有一个合适的解决方法

情况如下: 我有一个带有tinyMCE控件的表单,我将它加载到jquery对话框中。第一次的时候效果很好,然后他们关上它,打开一个新的。与tinyMCE控件的任何交互都会产生:

"Node cannot be used in a document other than the one in which it was created" 
它也不会用应该预先填充的文本填充控件

在jquery对话框中,beforeClose处理程序中包含以下脚本:

if (typeof tinyMCE != 'undefined') {
                $(this).find(':tinymce').each(function () {
                    var theMce = $(this);

                    tinyMCE.execCommand('mceFocus', false, theMce.attr('id'));
                    tinyMCE.execCommand('mceRemoveControl', false, theMce.attr('id'));
                    $(this).remove();
                });
            }
下面是我的tinyMCE安装脚本:

$('#' + controlId).tinymce({
        script_url: v2ScriptPaths.TinyMCEPath,
        mode: "none",
        elements: controlId,
        theme: "advanced",
        plugins: "paste",
        paste_retain_style_properties: "*",
        theme_advanced_toolbar_location: "top",
        theme_advanced_buttons1: "bold, italic, underline, strikethrough, separator, justifyleft, justifycenter, justifyright, justifyfull, indent, outdent, separator, undo, redo, separator, numlist, bullist, hr, link, unlink,removeformat",
        theme_advanced_buttons2: "fontsizeselect, forecolor, backcolor, charmap, pastetext,pasteword,selectall, sub, sup",
        theme_advanced_buttons3: "",
        language: v2LocalizedSettings.languageCode,
        gecko_spellcheck : true,
        onchange_callback: function (editor) {
            tinyMCE.triggerSave();
        },
        setup: function (editor) {
            editor.onInit.add(function (editor, event) {
                if (typeof v2SetInitialContent == 'function') {
                    v2SetInitialContent();
                }
            })
        }
    });
这里有什么明显的东西吗?我在封闭的b/c tinymce中有所有复杂的删除内容,它不喜欢在不删除的情况下删除它的html

setInitialContent()的内容只是为了让我可以预先加载他们的电子邮件签名(如果他们有)。不管有没有代码,它都会被破坏,所以这不是问题所在

由于这个问题,我被迫更新到3.4.9:

因此,如果有人能解决这个问题,这将有助于解决这种情况。我试过阿克诺西斯的建议,但没有成功

编辑:我原本以为这只会影响Firefox11,但我下载了10,它也会受到影响

编辑:好的,我把所有复杂的动态表单和链接都删减到一个相当简单的例子中

基本页的代码:

<a href="<%=Url.Action(MVC.Temp.GetRTEDialogContent)%>" id="TestSendEmailDialog">Get Dialog</a>
<div id="TestDialog"></div>
<script type="text/javascript">
    $('#TestSendEmailDialog').click(function (e) {
        e.preventDefault();

        var theDialog = buildADialog('Test', 500, 800, 'TestDialog');
        theDialog.dialog('open');
        theDialog.empty().load($(this).attr('href'), function () {

        });

    });

    function buildADialog(title, height, width, dialogId, maxHeight) {
        var customDialog = $('#' + dialogId);

        customDialog.dialog('destory');

        customDialog.dialog({
            title: title,
            autoOpen: false,
            height: height,
            modal: true,
            width: width,
            close: function (ev, ui) {

                $(this).dialog("destroy");
                $(this).empty();

            },
            beforeClose: function (event, ui) {

                if (typeof tinyMCE != 'undefined') {
                    $(this).find(':tinymce').each(function () {
                        var theMce = $(this);

                        tinyMCE.execCommand('mceFocus', false, theMce.attr('id'));
                        tinyMCE.execCommand('mceRemoveControl', false, theMce.attr('id'));
                        $(this).remove();
                    });
                }

            }
        });

        return customDialog;

    }

</script>

$(“#TestSendEmailDialog”)。单击(函数(e){
e、 预防默认值();
var theDialog=buildadilog('Test',500800,'TestDialog');
对话框(“打开”);
dialog.empty().load($(this.attr('href'),函数(){
});
});
函数buildDialog(标题、高度、宽度、对话框ID、最大高度){
var customDialog=$('#'+dialogId);
customDialog.dialog('destory');
自定义对话框({
标题:标题,,
自动打开:错误,
高度:高度,,
莫代尔:是的,
宽度:宽度,
关闭:功能(ev、ui){
$(此).dialog(“销毁”);
$(this.empty();
},
beforeClose:函数(事件、ui){
if(typeof tinyMCE!=“未定义”){
$(this).find(':tinymce').each(函数(){
var theMce=$(本);
tinyMCE.execCommand('mceFocus',false,theMce.attr('id');
tinyMCE.execCommand('mceRemoveControl',false,theMce.attr('id');
$(this.remove();
});
}
}
});
返回自定义对话框;
}
以及加载到对话框中的页面的代码:

<form id="SendAnEmailForm" name="SendAnEmailForm" enctype="multipart/form-data" method="post">
   <textarea cols="50" id="MessageBody" name="MessageBody" rows="10" style="width: 710px; height:200px;"></textarea>
</form>

<script type="text/javascript">

    $(function () {
        $('#MessageBody').tinymce({
            script_url: v2ScriptPaths.TinyMCEPath,
            mode: "exact",
            elements: 'MessageBody',
            theme: "advanced",
            plugins: "paste, preview",
            paste_retain_style_properties: "*",
            theme_advanced_toolbar_location: "top",
            theme_advanced_buttons1: "bold, italic, underline, strikethrough, separator, justifyleft, justifycenter, justifyright, justifyfull, indent, outdent, separator, undo, redo, separator, numlist, bullist, hr, link, unlink,removeformat",
            theme_advanced_buttons2: "fontsizeselect, forecolor, backcolor, charmap, pastetext,pasteword,selectall, sub, sup, preview",
            theme_advanced_buttons3: "",
            language: 'EN',
            gecko_spellcheck: true,
            onchange_callback: function (editor) {
                tinyMCE.triggerSave();
            }
        });
    });

</script>

$(函数(){
$('#MessageBody').tinymce({
脚本url:v2scriptpath.TinyMCEPath,
模式:“精确”,
元素:“MessageBody”,
主题:“高级”,
插件:“粘贴,预览”,
粘贴\保留\样式\属性:“*”,
主题\高级\工具栏\位置:“顶部”,
主题高级按钮1:“粗体、斜体、下划线、删除线、分隔符、左对齐、居中对齐、右对齐、满对齐、缩进、凸出、分隔符、撤消、重做、分隔符、numlist、bullist、hr、link、unlink、removeformat”,
主题\高级\按钮2:“字体大小选择、前景色、背景色、字符映射、粘贴文本、粘贴单词、选择全部、子、辅助、预览”,
主题\高级\按钮3:“”,
语言:"EN",,
gecko_拼写检查:对,
onchange\u回调:函数(编辑器){
tinyMCE.triggerSave();
}
});
});

我注意到一件非常有趣的事情,如果我将tinyMCE设置移动到load回调中,它似乎可以工作。但这并不是一个真正的解决方案,因为当我加载对话框时,我不知道代码中是否有tinyMCE控件

我将tinyMCE设置移动到一个函数中,然后在load()调用中,检查该函数是否存在,然后调用它,从而解决了这个问题

这不是最好的解决方案,但它确实有效