Welcome Guest, Not a member yet? Register   Sign In
How could i autosave in CKEDITOR?
#1

[eluser]basty_dread[/eluser]
Is there a way to autosave my work in ckeditor? i am using the latest ckeditor..

Can anyone please help me. many thanks.
#2

[eluser]Flemming[/eluser]
this post might help you:

http://cksource.com/forums/viewtopic.php...46&start=0

search the page for 'autosave'
#3

[eluser]basty_dread[/eluser]
hello i already saw this topic on that site,,

but i just dont know how could i implement this code.

can anyone explain it better?

Thanks a lot ..
#4

[eluser]John56[/eluser]
There is ready to use Autosave plugin for CKEditor.
Please have a look at - http://cksource.com/forums/viewtopic.php?f=18&t=24128

Regards,
John
#5

[eluser]talentsfromindia[/eluser]
Try this code hopefully it will be helpful for you-

1.
$(document).ready(function() {
2.
/* This section is CKEditor specific.
3.
It just updates the HTML fields to whatever
4.
content is in the CKEditor field.
5.
*/
6.
for(var name in CKEDITOR.instances) {
7.
CKEDITOR.instances[name].on("instanceReady", function() {
8.
// Set keyup event
9.
this.document.on("keyup", updateValue);
10.
// Set paste event
11.
this.document.on("paste", updateValue);
12.
});
13.

14.
function updateValue() {
15.
CKEDITOR.instances[name].updateElement();
16.
$(‘textarea’).trigger(‘keyup’);
17.
}
18.
}
19.

20.
/* This is the complete jQuery code for autosave.
21.
setTimeout() is called every 5 minutes while
22.
the inner function checks that the last save
23.
was at least 5 minutes ago before deciding
24.
to save.
25.
*/
26.
var lastSaveTime = 0;
27.
var currentTime = 0;
28.
// Edit chapter
29.
$("form").keyup(function() {
30.
$(".autosaved_msg").hide();
31.
window.setTimeout(
32.
function() {
33.
currentTime = new Date().getTime();
34.
if ((currentTime - lastSaveTime) > 300000 || lastSaveTime == 0) {
35.
$.post("/url/to/post/to", $("form").serialize(),
36.
function(response, status) {
37.
/* "1" is the response value I chose to return
38.
upon a successful save.
39.
*/
40.
if (response == 1 && status == "success") {
41.
$(".autosaved_msg").show();
42.
}
43.
}
44.
);
45.
lastSaveTime = new Date().getTime();
46.
}
47.
},
48.
300000
49.
);
50.
});
51.
});

#6

[eluser]John56[/eluser]
@talentsfromindia with all do respect but you code requires user to use jQuery and it does not work for every possible change made in CKEditor.

IMO this is better option - http://cksource.com/forums/viewtopic.php?f=18&t=24128




Theme © iAndrew 2016 - Forum software by © MyBB