Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2010-04-19 10:35:24

dkoper
New member
Registered: 2010-04-19
Posts: 8

Get state savesubmit button

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

#2 2010-04-19 19:25:44

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: Get state savesubmit button

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

#3 2010-04-21 06:22:43

dkoper
New member
Registered: 2010-04-19
Posts: 8

Re: Get state savesubmit button

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

#4 2010-04-21 20:06:43

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: Get state savesubmit button

You'll need to debug it probably.  Use firebug and throw an exception in the function/set a breakpoint so that you can inspect what is available.


James Sleeman

Offline

#5 2010-04-26 15:14:16

dkoper
New member
Registered: 2010-04-19
Posts: 8

Re: Get state savesubmit button

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

#6 2010-04-27 00:45:28

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: Get state savesubmit button

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

#7 2010-04-28 04:50:22

dkoper
New member
Registered: 2010-04-19
Posts: 8

Re: Get state savesubmit button

Hi Gogo,

That did the trick!

Thank you very much.

Offline

Board footer

Powered by FluxBB