Opened 15 years ago

Closed 15 years ago

#270 closed enhancement (worksforme)

Save edits on page unload

Reported by: ianb@… Owned by: gogo
Priority: lowest Milestone: 2.0
Component: Xinha Core Version: trunk
Severity: normal Keywords:


Right now if you edit some text, then go to another page (maybe go back, or follow some navigational link), and then come back to the editor your edits will be lost.

I believe fixing this just requires putting the content of the editable area into the textarea on page unload.

Change History (21)

comment:1 Changed 15 years ago by kim@…

  • Resolution set to invalid
  • Status changed from new to closed

In my opinion this has nothing to do with Xinha, this would have to be resolved by your own CMS. Xinha itself doesnt save any content, it lets you edit it. Same thing would be if you have a registration form and instead of clicking the submit button you click a navigational button, depending on the browser, all your inputs will be lost.

In our CMS I tell our customers that nothing is saved until they accually click the update button, giving them a fine way of getting out of the editing mode if they did something wrong. What if you messed up the HTML and click on the "reload" button or another navigational button to start over, and instead the content is infact saved because we developed a nifty save whatever you do function.

You could however easily acomplish your task with javascript and the unload as youself mention, a simple would probably do.

Im setting this ticked to invalid as I cant see this beeing related to Xinha as a WYSIWYG editor.

comment:2 Changed 15 years ago by niko

i think ianb is talking about something else, i think i is referring to a browser function that saves the entered form-data when you leave the page, and when you hit back this data will be filled in again into the fields.

FF has this feature, not sure if IE has it too.

and Xinha DOES allready put the content into the textarea on page unload! (at least there is code in htmlarea.js that should do it)
i have never actually test it

comment:3 Changed 15 years ago by niko

  • Resolution invalid deleted
  • Status changed from closed to reopened

ok, i did a simple test:

  1. open full example in FF
  2. change some text
  3. enter any url in the adressbar
  4. click back

the changed text should be here...

perhaps this is a problem only in full_example because the textareas are generated dynamically.

comment:4 Changed 15 years ago by kim@…

a browser function that saves the entered form-data when you leave the page, and when you hit back this data will be filled in again into the fields

You lost me, I know this being nice in formfields, if you need to submit same registration twice and only need to alter a little piece of registration (Like registering +1 domains for examaple). IE does this, Firefox doesnt. But if this is what you are referring to I dont see the relevance at the moment. How could javascript remember the html contents, when your not on that particular page - your somewhere else. Wouldnt you need a hidden frame or something on your website to stuff the html so you could get it back? As I said, you lost me, :)

And why should you enter a URL in the address bar? Then you would be telling the browser that I dont want to be on this page, get me out? The CMS should reload the content when you enter the WYSIWYG editor anyways.

Note :
What I have noticed however is that it seems that htmlarea adds a point in the history of the browser. (So does fckeditor) Meaning if you enter a page with the editor and hit the back button once, you will still be on the same page but before htmlarea initiated. I do remember having some issues here that the content of the editor didnt reappear if you hit the back button, or something (but why should you? Back buttons are bad in my opinion, hehe, I never expect a websystem to work, take a bank as an example, if you start wandering around forms with back and forth buttons). I tried to reproducse this problem in Firefox, but my Xinha (as of 12 May) do reload the contents every time, so this cant be it.

As I said in the beginning, you lost me, so I might just be rambling here...

comment:5 Changed 15 years ago by niko

this is NOT autocomplete or something i'm talking about this:

  1. go to
  2. enter "foobar" in the textfield (just enter it, don't submit the form)
  3. enter in your locationbar
  4. you get a 404 page
  5. press back in your browser
  6. the "foobar" is still in the textbox!! like this in IE6 and FF

  1. press forward again
  2. enter in the locationbar
  3. the "foobar" is gone!
  4. press back twice
  5. its here again

don't know how the feature is called, but it simplified said it saves the form-data kind of in the history, which is a very useful feature (when posting in forums for example).

...and this has nothing todo with xinha being twice in the history - because you don't click back when you are on the xinha-page.

...and the broken thing is that this doesn't work in combination with xinha - because onunload the xinha-contents needs to be written into the textarea. See line 1372 in htmlarea.js

i hope you understand what i wrote :D

comment:6 Changed 15 years ago by niko

...and i just tested this using examples/testbed.html and it IS broken. (IE and FF)

when i switch off JavaScript? it works.

comment:7 Changed 15 years ago by niko

  • Milestone set to Version 1.0

comment:8 Changed 15 years ago by kim@…

I havnt checked, but I think this has to do with the following, if i create this :

<input type="text" name="a" value="">

It will work as you mentioned, however if I do this :

<input type="text" name="a" value="something">

Then "something" will reapear instead of whatever you wrote in the field, it only works aslong as the value isnt set I think.

comment:9 Changed 15 years ago by niko

Checked this for FF and it does not work like you suggested. FF just ignores the value. (same with a textarea)

I also did some debugging on this, the onunload event is called, and the value of the textarea is set right. i have no idea what could be the problem here.

comment:10 Changed 15 years ago by gogo

  • Priority changed from normal to low

comment:11 Changed 15 years ago by anonymous

  • Priority changed from low to normal

This might be (and for me, it is) a big usability issue. If one submits the page to a "Preview and Submit" screen (much like the one right here), and the user decided they want to change something, the back button loses all previous edits. This works fine in the original htmlarea.

Looks like this is controlled by the body.unload event that calls:

textarea.value = editor.outwardHtml(editor.getHTML());

The textarea value is indeed set to the current value (proven by a simple alert( + ' = '+textarea.value)) but it somehow doesn't retain the value when you come back to the page.

comment:12 Changed 15 years ago by gogo

It may be necessary to set textarea.innerHTML

comment:13 Changed 15 years ago by niko

Setting textarea.innerHTML didn't help.

i wrote a little testcase that sets the value of a textarea on onload:

  <script language="JavaScript">
    window.onunload = function() {
        document.getElementById('foo').value = "fooobar";
  <textarea id="foo">asdfasdf</textarea>

....which works for me

comment:14 Changed 15 years ago by gogo

But isn't that exactly what we do now?

comment:15 Changed 15 years ago by niko

yes, we do...
i even made the textarea visible in the onunload and it shows the right content.

i can't do anything more on this ticket, somebody should probably do some internal FF-debugging!?

comment:16 Changed 15 years ago by anonymous

It's not FF only. I can reproduce it in IE, Netscape 7.1 and 7.2 too. The field definitely sets the value right, if you do a form-post it goes in correctly. The funny thing is that original HTMLArea works fine, and I even tried the same (equivalent) assignment in the onLoad handler with no luck. Something must have changed in the way the variables are being assigned somewhere.

comment:17 Changed 15 years ago by gogo

  • Milestone changed from Version 1.0 to 2.0

I don't know what's going on here, the value is definatly set on it's way out, but it's different coming back. I'm going to bump this to V2.0 because I don't think it's worth blocking 1.0 with it.

comment:18 Changed 15 years ago by wikiwhacker

  • Severity changed from normal to blocker

This problem was cited in ticket #537, which was deleted. This is a show-stopper problem for us to use Xinha for 70 authors. If there's no fix, then Xinha is no longer an option.

comment:19 Changed 15 years ago by gogo

wikiwhacker: I don't think #537 is a dup of this, see my comments there.

comment:20 Changed 15 years ago by mharrisonline

I know this isn't the way you want this to work, but you could provide a preview button that opens a resizable popup window with scrollbars. That is what I do, and it really shows well what the page will look like. If you don't want the preview to be in a new window, then perhaps it could be in a div or iframe that could temporarily cover the editor. Then, Xinha never needs to go away and the editor contents are undisturbed.

comment:21 Changed 15 years ago by anonymous

  • Priority changed from normal to lowest
  • Resolution set to worksforme
  • Severity changed from blocker to enhancement
  • Status changed from reopened to closed

I don't think this is a blocking feature, it can be solved outside xinha, the browser back button is not a matter of an editor since each browser maintain cronology in a different way.

Note: See TracTickets for help on using tickets.