How to store TinyMCE after publishing in an UpdatePanel

advertisements

When I click a button that causes a postback on the UpdatePanel it calls the tinyMCE.triggerSave().

It reloads the panel and the editor show up again, but when I try to call tinyMCE.triggerSave() the second time I get the following error:

g.win.document is null

I though it was getting the old instance, but I'm also removing the control (tinyMCE.execCommand('mceRemoveControl',false,'Editor');) after I call the save. Even so it still crashes the second time.

How should I fix it?


After much confusion I discovered that the fix which @André Gadonski posted no longer works in TinyMCE version 4. Not only does it not work, it provides no error feedback to the console!

The new command is mceRemoveEditor

Source: http://www.tinymce.com/forum/viewtopic.php?id=31256

I found that this can either be used directly before re-initalising TinyMCE or just before the ASP update panel is refreshed using;

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_beginRequest(BeginRequestHandler);

function BeginRequestHandler(sender, args) {
    tinymce.execCommand('mceRemoveEditor', true, 'EditorID');
}