Saturday, December 22, 2007

TinyMCE, ASP.NET AJAX, and Auto-Save

I'm working on a ASP.NET web app that will allow administration of a new product feature and some of that content can be several paragraphs long. I'm using TinyMCE for those longer pieces and the ASP.NET AJAX Timer control to auto-save the form.

What I noticed is that any field connected to TinyMCE wouldn't be saved on auto-save, but would be saved just fine with a full Save button click and PostBack -- even though the same method was being used.

The details are a little hazy, but there's a layer in TinyMCE that disconnects what you see in your browser as you're typing from the actual textarea. On PostBack, the two were reconnected, but only then. After some searching I found references to TinyMCE's triggerSave() method. So, my hack to deal with this was to add the following immediately after tinyMCE.init():
setInterval("tinyMCE.triggerSave()", 30000);
This will call triggerSave() every 30 seconds. If I find a better way to handle this with the Timer control I'll update this post.

No comments: