Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#799 closed enhancement (invalid)

How to check if the content have be changed by user

Reported by: Emanuel Dejanu <emanuel@…> Owned by: gogo
Priority: low Milestone:
Component: Xinha Core Version: trunk
Severity: normal Keywords: dirty, saving
Cc:

Description

Hi,

Is there a easy/fast way to know if user have change the content?
Now I use:

var g_strOriginalText = g_editor.getInnerHTML();

function OnSave?()
{

var strHTML = g_editor.getInnerHTML();
if (strHTML != strOriginalText)

DoSaving?();

}

but this is very slow. I will like a function g_editor.IsDirty?().

Change History (2)

comment:1 Changed 13 years ago by mokhet

  • Priority changed from highest to low
  • Resolution set to invalid
  • Severity changed from blocker to enhancement
  • Status changed from new to closed

I dont get it. When do you want to check ? IMO, the easiest way is to compare the value and the defaultValue of your textarea onsubmit

<script type="text/javascript">
function check(frm)
{
 var T = frm.elements['I_AM_THE_XINHA_TEXTAREA'];
 if ( T.value == T.defaultValue )
 {
  alert('No change to commit');
  return false;
 }
 return true;
}
</script>

<form onsubmit="return check(this);">
<textarea id="I_AM_THE_XINHA_TEXTAREA">

comment:2 Changed 13 years ago by mokhet

dohh, where is my post ??? let's try again :p

<script type="text/javascript">
function check(frm)
{
 var T = frm.elements['I_AM_THE_XINHA_TEXTAREA'];
 if ( T.value == T.defaultValue )
 {
  alert('No change to commit');
  return false;
 }
 return true;
}
</script>

<form onsubmit="return check(this);">
<textarea id="I_AM_THE_XINHA_TEXTAREA"></textarea>
</form>

Since it's not Xinha related, i'm closing this ticket. Please ask in forum if you cant resolve your issue.

Note: See TracTickets for help on using tickets.