Hello All,
I just started using the FCKEdtitor in my Web Application, and I have a question about the Javascript API. Previously I was using NicEdit on Divs to do Inline editing. I had it setup so that whenever a user clicked with in a div a Javascript event would fire in the background and if the user left the page before saving they would be notified that they need to save the page.
I have about 6 Textareas on the page that are being turned into Editors. I'am using jQuery to loop through each of the editors and apply the FCK Editor with the jQuery FCK Editor Plugin. I was wondering how I would go about adding a listening method to these 6 FCK editors so that whenever the user focused on the textareas the save message would fire.
Thank you for the help!
Steve
I just started using the FCKEdtitor in my Web Application, and I have a question about the Javascript API. Previously I was using NicEdit on Divs to do Inline editing. I had it setup so that whenever a user clicked with in a div a Javascript event would fire in the background and if the user left the page before saving they would be notified that they need to save the page.
I have about 6 Textareas on the page that are being turned into Editors. I'am using jQuery to loop through each of the editors and apply the FCK Editor with the jQuery FCK Editor Plugin. I was wondering how I would go about adding a listening method to these 6 FCK editors so that whenever the user focused on the textareas the save message would fire.
Thank you for the help!
Steve
Re: Listening for 'Focus' on multiple FCKEditors
An alternative is to check whether there are modifications not yet saved on submit: viewtopic.php?f=6&t=12018&p=31667&hilit=isdirty#p31667
Re: Listening for 'Focus' on multiple FCKEditors
function windowUnLoadSave() {
window.onbeforeunload = function () {
checkFCKeditors();
if (unSaved == 0) {
return "There are unsaved changes on this page. Please Make sure to save your changes for before exiting.";
return false;
}
}
}
//Check to see if there have been changes
function checkFCKeditors()
{
var fckeditorName, editorInstance;
if (window.FCKeditorAPI)
{
for (fckeditorName in FCKeditorAPI.Instances) // Use __Instances in FCKeditors prior to version 2.6
{
if ((editorInstance = FCKeditorAPI.GetInstance(fckeditorName)).IsDirty())
{
var unSaved = 0;
return true;
}
}
}
return false;
}
Re: Listening for 'Focus' on multiple FCKEditors
Try
Re: Listening for 'Focus' on multiple FCKEditors
I think also the method IsDirty() is always triggered whenever FCKEditor goes through my Textareas and turns them in to the editor windows. So maybe this isn't the best method to check to see if the editor has been focused on or the content has been changed.
BTW Thank you for your help. It is much appreciated.
Re: Listening for 'Focus' on multiple FCKEditors
Just use 'unSaved = 0;' instead of 'var unSaved = 0;', or when testing the value, use 'window.unSaved'.
IsDirty() is specifically to check if the content in the editor has been changed, see http://docs.fckeditor.net/FCKeditor_2.x ... Script_API