开发者

How to disable TinyMCE confirm dialog

开发者 https://www.devze.com 2023-02-27 08:02 出处:网络
Does anyone know how to disable TinyMCE alerts, and confirms. The confirm in talking about says: This page is asking you to confirm

Does anyone know how to disable TinyMCE alerts, and confirms. The confirm in talking about says:

This page is asking you to confirm that you want to leave - data you have entered may not be saved Leave Page - Stay on Page

I've written my own stuff that detects if the page data has been change so I don;t want TinyMCE to worry. I found the function in the TinyMCE source so I'm about to overwrite it but I want to know if anyone know开发者_JAVA技巧s a better way to accomplish this. Thanks.


To remove the message, just disable the autosave plugin, that's what adds the onunload prompt.

Simply don't load the plugin in your TinyMCE initialization script.


As per a request I'm adding this here to show my solution which has worked great:

My solution thanks to a link provided by Madmartigan, on the TinyMCE forum. Getting rid of the autosave plugin did not work, I ended up writing this:

window.onbeforeunload = function() {};

And it got rid of the popup. Looks like it could be a bug with TinyMCE, since the init code I have I copied off their demo.


I set it as a param when initializing (autosave_ask_before_unload):

tinymce.init({
        mode: 'textareas',
        menubar: false,
        statusbar: false,
        language: 'sv_SE',
        autosave_ask_before_unload: false,
        ...


If the problem you're having is just that the content isn't actually dirty, maybe because you replaced it programmatically, you can explicitly mark the editor as not dirty like this:

tinyMCE.activeEditor.isNotDirty = true


Neither of the above answers worked for me with Joomla 3.3.2 and JCE 2.5.11. Although this did work: Inside the file -

components/com_jce/editor/tiny_mce/plugins/autosave/editor_plugin.js,

I changed

editor.getParam("autosave_ask_before_unload",TRUE)

to

editor.getParam("autosave_ask_before_unload",FALSE)

Apparently on autosave unload, it prompts the confirm box. This disables the unload confirm completely. From what I tested, it worked in IE, Chrome, and FF.

0

精彩评论

暂无评论...
验证码 换一张
取 消