I've created a plugin to automatically save a draft of the FCK Editor content in the background as you type, at a set interval. This is much like you would see in most good editors and web applications, e.g. googlemail.
It's inspired by and built on Paul Moers ajaxPost plugin, so credit to him is due.
In addition I've added handling on the Window Close event, or onBeforeUpdate as it's called, to stop someone from closing the editor page without saving. Hopefully this is something that can be considered for future releases as a standard option.
So far I've only tested in IE6 and Firefox 1.5, so any additional feedback or experiences of other browsers appreciated.
http://sourceforge.net/tracker/index.ph ... tid=737639
There's an online demo here:
http://greenmap.sourceforge.net/fck_demo/
Tue, 05/29/2007 - 08:35
#1
onBeforeUpdate - should be onbeforeunload
Actually the browser event I mentioned is onbeforeunload - not onBeforeUpdate as I stated above. My point of reference for this was the excellent article "Mastering the Back Button" from http://www.hunlock.com/blogs/Mastering_ ... Javascript
There were a couple of issues to overcome with this:
1) We do not want to fire the confirmation dialog if the page is unchanged. Using the IsDirty flag in FCKEditor was the obvious option. I wanted something more complex - to save a draft and know if any changes have been made since the last draft was saved. We can do this by listening to the onSelectionChange event. I found that this event fires when the editor is loaded, so I count to three before I set the custom IsDirty property.
2) We do not want to fire the confirmation dialog when the document is saved normally. In order to achieve this I had to set a flag and listen for the FCK.LinkedField.form.onsubmit event to disable the flag.