简体   繁体   English

使用ajaxSubmit替换DOM部分时,我应该对tinyMCE做什么?

[英]What should I do with tinyMCE when replacing sections of the DOM using ajaxSubmit?

On a multi-tab page, some tabs submit process changes the content of other tabs through an ajaxSubmit . 在多选项卡页面上,某些选项卡的submit过程通过ajaxSubmit更改其他选项卡的内容。 If the other tab contains active tinyMCE edits what should I do to that tab before replacing it's content and what should I do (if anything) after the replacement? 如果另一个选项卡包含活动的tinyMCE ,则在替换其内容之前我应该​​对该选项卡进行什么操作,替换后应该做什么(如果有)?

Currently the code performs tinyMCE.execCommand("mceRemoveControl", true, ed_id); 当前,代码执行tinyMCE.execCommand("mceRemoveControl", true, ed_id); on all editors in the target tab and relies on the normal functionality of the system to bring them back after the change. 在“目标”选项卡中的所有编辑器上运行,并依靠系统的正常功能将它们在更改后恢复。 Is that all that is necessary? 这就是所有必要的吗? I am experiencing obscure exceptions within the tinyMCE code after the change but it is difficult to discover the cause. 更改后,我在tinyMCE代码中遇到了难以理解的异常,但是很难找到原因。

The error itself is SCRIPT5022: IndexSizeError - tiny_mce.js (1,78075) but I doubt that is specifically relevant. 错误本身是SCRIPT5022:IndexSizeError-tiny_mce.js(1,78075),但我怀疑这是否特别相关。

TinyMCE v3.4.5 TinyMCE v3.4.5

As i said in my Comments TinyMCE does not play well with AJAX there are loads of problems with it i have tried many times to get it to work. 正如我在我的评论中说的那样,TinyMCE在AJAX上不能很好地发挥作用,但它有很多问题,我已经尝试过很多次才能使其正常工作。

In the end i switched to CKEditor so if you would like to try and use it you can here is the code you need for the ajaxSubmit() options 最后,我切换到了CKEditor,因此,如果您想尝试使用它,可以在这里找到ajaxSubmit()选项所需的代码。

beforeSubmit:function{
   for(var instanceName in CKEDITOR.instances) {
        try{
            CKEDITOR.instances[instanceName].destroy();
        }catch(e){
        }
    }
}

the above code will remove CKEditor cleanly before you submit the following is how to re-inistialize CKEditor when your ajax has finished again this is a option for ajaxSubmit() : 上面的代码将在提交之前彻底清除CKEditor,以下是当ajax重新完成后如何重新初始化CKEditor的方法,这是ajaxSubmit()一个选项:

success:function(){
    // do what you need to update your DOM and then final call is
    $("editorSelector").ckeditor(options);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AjaxSubmit不是DOM重新加载的函数 - AjaxSubmit is not a function on DOM reload TinyMCE初始化应该在dom ready事件内部吗? - TinyMCE initialization should be inside dom ready event? 我在使用jQuery Mobile时如何操作DOM? - How do I manipulate the DOM when I using jQuery Mobile? 赛普拉斯在使用条件时出现“pointer-events: none”错误,我该怎么办? - Cypress results with "pointer-events: none" error when using condition, what should I do? 如何在jQuery中取消由ajaxSubmit()启动的文件上传? - How do I cancel a file upload started by ajaxSubmit() in jQuery? 使用 mocha javascript 时如何模拟 dom 元素? - How do I mock dom elements when using mocha javascript? 如何在上传文件之前使用ajaxSubmit获取文件大小 - How to get the file size when using ajaxSubmit before uploading file 动态DOM操作功能:如何改进它,我应该使用它,以及它在做什么? - Dynamic DOM Manipulation Function: How To Improve It, Should I Be Using It, & What's It Doing Here? 我正在编写一个 discord 机器人,但是当我使用 ping 命令时,它会显示 0 毫秒。 我应该怎么办? - I'm coding a discord bot, but when I'm using the ping command its shows me 0 ms. what should i do? 将表单发送到服务器时,我应该怎么做才能修复此错误? - What should I do to fix this error when sending the form to the server?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM