Opened 10 years ago

Closed 7 years ago

#929 closed defect (fixed)

Save changes on page unload

Reported by: ray Owned by: gogo
Priority: normal Milestone:
Component: Xinha Core Version:
Severity: normal Keywords:
Cc:

Description

Frmo the forum http://xinha.gogo.co.nz/punbb/viewtopic.php?id=942

#1 Yesterday 23:11:03

Correct behavior when user navigates back to a page with Xin

A user is editing content with Xinha editor. Navigates to another page. Clicks back to go back to Xinha editor page. The content the user entered is gone. This is not the expected behavior. Does this always happen with xinha or might it be a configuration issue?

#2 Today 00:44:24

Re: Correct behavior when user navigates back to a page with Xin

This is an expected behaviour. Xinha initalizes with contents of TEXTAREA element associated with it. Is the user navigates to the other page without submitting the form, there is no way for the server serving HTML page to determine "previous" state of the textarea.

Some browsers do populate textareas and/or input field based on their cached contents, but AFAIK Xinha can't access these values.

If you want to be able to save the content while editing the document, please look at the SaveSubmit plugin.

#3 Today 00:48:15

Re: Correct behavior when user navigates back to a page with Xin

In this case the server is never contacted, the page is loaded from the browser cache.
I asked an associate about other wysiwyg editors, and he said TinyMCE has the expected behavior (ie: edits are not lost). I will research some more. Perhaps there is some way to populate a placeholder textarea and reload xinha with it when the browser goes back to the cached page.

#4 Today 02:51:15

Re: Correct behavior when user navigates back to a page with Xin

Ie: http://tinymce.moxiecode.com/example_fu … ample=true This works as expected. If you enter content in tinymce then browse to a new page then click "back" the content is still there.

This: http://xinha.gogo.co.nz/xinha-nightly/e … ample.html does not.

#5 Today 04:00:23

Re: Correct behavior when user navigates back to a page with Xin

I found this code

  // add a handler for the "back/forward" case -- on body.unload we save
  // the HTML content into the original textarea.
  Xinha.prependDom0Event(
    window,
    'unload',
    function()
    {
      textarea.value = editor.outwardHtml(editor.getHTML());
        return true;
    }
  );

Which appears to save the content in the textarea before you leave the page. So it looks like the problem is when I come _back_ to the page its somehow getting the wrong value.

#6 Today 11:40:47

Re: Correct behavior when user navigates back to a page with Xin

yeah I think by the time an onunload function has been called, any changes are going to be lost as they're not remembered by the browser past that point


#7 Today 16:14:14

Re: Correct behavior when user navigates back to a page with Xin

Interesting if the browser loses the changes. I poked around the source of TinyMCE and it appears to do the same thing. One thing I did not see if moving the textarea inside the iframe. That is Xinha changes the DOM and moves the textarea for the form inside the iframe, at least that is what appears to happen.

Change History (3)

comment:1 Changed 10 years ago by ray

Yes, it seems the browser looses the association with the original textarea. I've tried it without moving the textarea (btw. it's not moved inside the iframe, only in the table framework), but unfortunately without any success :(

comment:2 Changed 10 years ago by ray

rev [768]: fixed for Mozilla. As I noticed tinyMCE doesn't have this in IE either...

The point here was the additional form elements generated by Xinha (toolbar selects, inline dialogs)

comment:3 Changed 7 years ago by gogo

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

So, fixed.

Note: See TracTickets for help on using tickets.