I'd like to do the following efect:
1. The user click on the "Save" button, but the page don't submit.
2. A function will be called to save the contents by ajax.
I don't know how to do that in CKEditor.
Please help me & Thanks in advance.
Jasper
1. The user click on the "Save" button, but the page don't submit.
2. A function will be called to save the contents by ajax.
I don't know how to do that in CKEditor.
Please help me & Thanks in advance.
Jasper

Re: How to get "Save" button event? I want to save by
Re: How to get "Save" button event? I want to save by
http://ajithmanmadhan.wordpress.com/200 ... ar-button/
Re: How to get "Save" button event? I want to save by
Re: How to get "Save" button event? I want to save by
Isn't there anybody out there that can help?
Seems like more than one person is looking for an answer to this (me too)...
thanks
Steven
Re: How to get "Save" button event? I want to save by
Re: How to get "Save" button event? I want to save by
Re: How to get "Save" button event? I want to save by
I think setInterval is the way for your solution, but I don't know why the function doesn't exist.
Can you give me some sample files to take a test. Maybe I can find out why.
Re: How to get "Save" button event? I want to save by
CKEDITOR.plugins.add( pluginName, { init : function( ajaxAutoSave) { var command = editor.addCommand( ajaxAutoSave, ajaxAutoSaveCmd ); command.modes = { wysiwyg : !!( editor.element.$.form ) }; editor.ui.addButton( 'ajaxAutoSave', { label : 'ajaxAutoSave', command : pluginName, icon:this.path+'images/ajaxAutoSaveClean.gif' }); setInterval("editor.execCommand('ajaxAutoSave')",30000); } });Re: How to get "Save" button event? I want to save by
First:
In the Init, it can't know what editor is...
So you should write like if(doAutoSave) setInterval(doAutoSave,30000); while doAutoSave is a javascript function. And you should refer your editor like CKEDITOR.instances.TextBody.getData();
Second:
Write your setInterval outside the init function. I write javascript with jquery here.
You should write like this:
<script language='javascript'>
setInterval(doAutoSave, 30000);
function doAutoSave()
{
var data = CKEDITOR.instances.TextBody.getData();
$.ajax(.......)
}
</script>
Re: How to get "Save" button event? I want to save by
A million thanks!
Re: How to get "Save" button event? I want to save by
TextBody is the ID of the textarea.
You can check some CKEditor samples to figure out.
Re: How to get "Save" button event? I want to save by
However, I wish there is a way to change the icon of the button when it's doing the ajax call, and change back when it's done, so users know their draft was saved. is there a way to change the icon path and then change it back for a button? I guess it would also be nice to change the label to reflect the last time their draft was saved.
my plugin code is reproduced below for those who might be interested. ajaxAutoSaveCmd is defined in the same format as the 'save' command. just go to the stock 'save' plugin and look at how they do it. pluginName is defined as
CKEDITOR.plugins.add( pluginName, { init : function( editor ) { var command = editor.addCommand( pluginName, ajaxAutoSaveCmd ); command.modes = { wysiwyg : !!( editor.element.$.form ) }; editor.ui.addButton( 'ajaxAutoSave', { label : 'ajaxAutoSave', command : pluginName, icon:this.path+'images/ajaxAutoSaveClean.gif' }); } }); var check_dirty_save_and_reset = function(){ if(CKEDITOR.instances.FCKeditor1.checkDirty()){ CKEDITOR.instances.FCKeditor1.execCommand('ajaxAutoSave'); CKEDITOR.instances.FCKeditor1.resetDirty(); } } setInterval(check_dirty_save_and_reset,30000); })();Re: How to get "Save" button event? I want to save by
(function() { var pluginName = 'ajaxAutoSave'; CKEDITOR.plugins.add( pluginName, { /** * @param editor The editor instance to which the plugin bind. */ init : function( editor ) { var commandDefinition = { // This command works in both editing modes. modes : { wysiwyg:1, source:1 }, // This command will not auto focus editor before execution. editorFocus : false, // This command requires no undo snapshot. canUndo : false, exec : function( editor ) { // Simulate Do ajax post ... setTimeout( function() { // Simulate on ajax callback successful ... editor.resetDirty(); // No more busy state. command.setState( CKEDITOR.TRISTATE_OFF ); }, 1000 ); } }; var commandName = pluginName, command = editor.addCommand( commandName, commandDefinition ); editor.ui.addButton( 'AjaxAutoSave', { label : editor.lang.ajaxAutoSaveButtonLabel, command : commandName, icon:this.path + 'images/ajaxAutoSaveClean.gif' } ); // Schedule auto ajax save only if content is changed. var autoAjaxSave = setInterval( function() { if( editor.checkDirty() ) { editor.execCommand( commandName ); // Indicate busy state on this command. command.setState( CKEDITOR.TRISTATE_DISABLED ); } }, editor.config.autoAjaxSaveInterval || 30000 ); // Stop the job after editor is down. editor.on( 'destroy', function() { clearInterval( autoAjaxSave ); } ); } } ); })();Re: How to get "Save" button event? I want to save by
Re: How to get "Save" button event? I want to save by
Re: How to get "Save" button event? I want to save by
how does a person install this modification to fresh install of the editor?
what if any supporting addons need to also be added?
thank you very much
this autosave, will surely be a lifesaver
Re: How to get "Save" button event? I want to save by
I did an autosave function on my form using,
It worked a treat and all the content is going to the database but now if i hit enter twice it wont save anything after it so i put some text like this:
line one
line two
It will only save the first line with the text 'line one'
have you encountered this. Any help will be great.
Thanks
Nick
Re: How to get "Save" button event? I want to save by
I'm a newbie in the area and can't put this to work, can i have some help ?
Re: How to get "Save" button event? I want to save by
http://source.wendt.se/git/?p=wiki.git; ... f4cf62db37
http://wendt.se/wiki/TestPage
Re: How to get "Save" button event? I want to save by
(function() { var pluginName = 'AjaxSave'; // var sNmEditor = ''; CKEDITOR.plugins.add( pluginName, { init : function( editor ) { var commandDefinition = { modes : { wysiwyg:1, source:1 }, editorFocus : false, canUndo : false, exec : function( editor ) { setTimeout( function() { editor.resetDirty(); command.setState( CKEDITOR.TRISTATE_OFF ); }, 1000 ); } }; var commandName = pluginName, command = editor.addCommand( commandName, commandDefinition ); editor.ui.addButton( 'AjaxSave', { label : editor.lang.ajaxAutoSaveButtonLabel, command : commandName, icon: "plugins/ajaxsave/images/ajaxSaveClean.gif" } ); var autoAjaxSave = setInterval( function() { if( editor.checkDirty() ) { //blur(sNmEditor) sNmEditor = editor.name; //focus(sNmEditor) content = CKEDITOR.instances[sNmEditor].getData(); if (content==""){ content=" "; } atualiza(url, content); editor.execCommand( commandName ); command.setState( CKEDITOR.TRISTATE_DISABLED ); } }, editor.config.autoAjaxSaveInterval || 2000 ); editor.on( 'destroy', function() { clearInterval( autoAjaxSave ); } ); } } ); })(); var Caminho = document.getElementById("Caminho").value; var iNrProcesso = document.getElementById("iNrProcesso").value; var iNrProcessoVara = document.getElementById("iNrProcessoVara").value; var iNrProcessoAno = document.getElementById("iNrProcessoAno").value; var url = "/saveAdapter/saveAdapter.asp"; function atualiza(url,valores) { req = null; // Procura por um objeto nativo (Mozilla, Safari, IE7+ ...) if (window.XMLHttpRequest) { req = new XMLHttpRequest(); req.onreadystatechange = processReqChange; req.open("POST",url,true); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); req.send('content=' + encodeURIComponent(valores) + '&Caminho=' + Caminho + '&sNmEditor=' + sNmEditor + '&iNrProcesso=' + iNrProcesso + '&iNrProcessoVara=' + iNrProcessoVara + '&iNrProcessoAno=' + iNrProcessoAno); } // Procura por uma versao ActiveX (IE) else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); if (req) { req.onreadystatechange = processReqChange; req.open("POST",url,true); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); req.send('content=' + encodeURIComponent(valores) + '&Caminho=' + Caminho + '&sNmEditor=' + sNmEditor + '&iNrProcesso=' + iNrProcesso + '&iNrProcessoVara=' + iNrProcessoVara + '&iNrProcessoAno=' + iNrProcessoAno); } } } function processReqChange(){ if (req.readyState == 4) { if (req.status == 200) { document.getElementsByName(sNmEditor).innerHTML = req.responseText; } else{ if(req.status == 500){ alert("Erro interno do servidor !!!<br>" + unescape(req.responseText.replace(/\+/g," "))); } else{ alert("Houve um problema ao obter os dados:\n" + req.statusText); } } } }Re: How to get "Save" button event? I want to save by
http://cksource.com/forums/viewtopic.php?t=24128