You are not logged in.
Pages: 1
Hi,
Does anybody know how to get the state of the savesubmit button?
I know how to use the plugin's command from outside the editor by using
function saveSubmit() {
var editor = Xinha.getEditor('area1');
editor._toolbarObjects.savesubmit.cmd(editor);
}
But I don't know how to get the state of the button (visually the button has two states: Red and Green).
I need this to alert users when content is not saved when they navigate away from the editor.
Offline
Try this
function getState()
{
var editor = Xinha.getEditor('area1');
return editor.plugins.SaveSubmit.instance.getChanged();
}
In theory returns true when content is changed, false otherwise.
James Sleeman
Offline
Hi Gogo,
Thank you for the quick reply, but the function keeps returning false no mather what the state of the button is.
Last edited by dkoper (2010-04-21 06:36:31)
Offline
Hi,
The function that is called from the save-submit.js:
SaveSubmit.prototype.getChanged=function(){
if(this.initial_html===null){
this.initial_html=this.editor.getInnerHTML();
}
if(this.initial_html!=this.editor.getInnerHTML()&&this.changed==false){
this.changed=true;
return true;
}else{
return false;
}
};
I can see what it is meant to do but I have no idea how to debug this or where to throw an exception. If I try to return (for instance) this.editor.getInnerHTML(), instead of false, I get an stack overflow error...
Offline
It looks like it's intention is that it shoudl only report true ONCE, and after that it always returns false.
Try just removing the &&this.changed==false conditional to shortcircut that and return true if there has been a change at any time.
James Sleeman
Offline
Hi Gogo,
That did the trick!
Thank you very much.
Offline
Pages: 1