Hi!
I am trying to implement CKeditor to my project. As i have it in the past a lot of times that i accidentally navigated away from the editor window, i want to have a alert message before that happens.
I managed it to create a alert message with this code ...
This code cases Firefox to show a alert message before i leave the page. But this ONLY if the content in the editor has changed. That works great so far. But the alert box shows as well when the Save button is pressed.
I would like to show the message only when
1.) The content has changed AND
2.) The user did not press the "save" button.
Thanks, Bye
Gerhard
I am trying to implement CKeditor to my project. As i have it in the past a lot of times that i accidentally navigated away from the editor window, i want to have a alert message before that happens.
I managed it to create a alert message with this code ...
ckeditor = CKEDITOR.instances.note_editor;
ckeditor.execCommand('maximize');
window.onbeforeunload = function() { return before_leave_page(); };
window.onunload = function() { return before_leave_page(); };
function before_leave_page () {
if (ckeditor.checkDirty() === true) {
return 'You have unsaved changes in this note. Click Cancel now, then "Save" to save them. Click OK now to discard them.';
}
};
This code cases Firefox to show a alert message before i leave the page. But this ONLY if the content in the editor has changed. That works great so far. But the alert box shows as well when the Save button is pressed.
I would like to show the message only when
1.) The content has changed AND
2.) The user did not press the "save" button.
Thanks, Bye
Gerhard

Re: Show notification before user leaves the page
Re: Show notification before user leaves the page
Anybody who can help me with this???
The development team rejected any support so far and i did not find anything in the documentation about it. Any help would be great!!!
Re: Show notification before user leaves the page
Re: Show notification before user leaves the page
Re: Show notification before user leaves the page
Re: Show notification before user leaves the page
http://www.kriesi.at
// Save the current onclick event code from the save button and delete it the event code $('.cke_button_save').live('mouseover', function() { if(! oldOnClick) { oldOnClick = this.onclick; this.onclick= ""; } }); // Reasign a new function to the onclick event of the save button $('.cke_button_save').live('click', function() { reload_prompt = false; //alert( oldOnClick); oldOnClick(); });A possible solution
I came across this thread searching on Google. A bit late, but maybe others are searching the same.
If found this code helpful. There is only a typo, ")" missing at the end:
$(function(){ document.body.onbeforeunload = function() { for(editorName in CKEDITOR.instances) { if (CKEDITOR.instances[editorName].checkDirty()) { return "Unsaved changes present!" } } } });I haven't tested the "robuster implementation".