Announcement

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

#1 2007-12-12 14:35:11

speterson
Xinha Community Member
Registered: 2005-03-17
Posts: 12

Moving the editor around on a page

We use Xinha in an application that has multiple sections of copy to edit on a single page.  In order to avoid the start-up and overhead of having a different Xinha editor for each content section, we have taken the approach of having a single textarea/editor and moving this instance around to the appropriate place on the document.  Based on prior comments, we have done this by deactivating the editor, moving the text area using appendChild, re-setting the content, then reactivating the editor.  It works beautifully in IE (if I do say so myself), but not in Firefox.  A page that uses this method is available here: http://www.frontierproductions.net/xinh … _test.html

We tried it again with the latest Xinha .94, but have the same problem. Can anyone suggest a strategy that might work in both browsers? 

Thanks,

Steve

Offline

#2 2007-12-13 07:51:22

hilope
Xinha Community Member
Registered: 2006-06-06
Posts: 26
Website

Re: Moving the editor around on a page

Wow, that's a nice feature!

But it works in my Firefox (2.0.0.11)

Offline

#3 2007-12-13 14:41:51

speterson
Xinha Community Member
Registered: 2005-03-17
Posts: 12

Re: Moving the editor around on a page

That's strange, because I have the same version of Firefox (2.0.0.11) and it does *not* work.

The test I do is click on the window with the editor and type in some text.  Then click on the other text location, causing the editor to pop up over there and type in some additional text.  If you try this in IE, you will see that both text blocks are maintained and you are able to add to them and edit them as you wish.  But in Firefox, when I click on the second text location, the editor moves but will not allow me to type any text in, plus the text that was already there ('Click in here to edit this text') disappears.

What??!!

Offline

#4 2007-12-13 15:03:22

LDB
New member
Registered: 2007-12-13
Posts: 1

Re: Moving the editor around on a page

Nice Feature!

If you run your test and click the 'html' button when jumping between windows , the test works.

May help find your bug.

Offline

#5 2007-12-14 11:15:13

speterson
Xinha Community Member
Registered: 2005-03-17
Posts: 12

Re: Moving the editor around on a page

Thanks for pointing out that it works in 'Code View' mode; I had not noticed that. 

In Firefox, after deactivating the editor, moving the location of the div holding the textarea field using DOM, then reactivating the editor, the xinha function editorIsActivated() returns false.

This makes me guess that some, but not all of the 'activateEditor' event function is completing.  I looked through the Xinha code and confess that I am in over my head when trying to pinpoint the problem.  Rather than deactivate/activate, is there a way to completely destroy the editor then create a new one after moving the div to the new location?

Offline

#6 2007-12-19 16:14:36

Practicality
Xinha Community Member
Registered: 2007-02-15
Posts: 24

Re: Moving the editor around on a page

Well, recently, I had a similar problem and used a really old solution posted from some time ago.

(http://xinha.gogo.co.nz/punbb/viewtopic.php?id=48)

The solution still works. It looks like this:

    var editor = xinha_editors.NAMEOFYOUREDITOR
    
    editor.setMode('textmode');
    editor._htmlArea.style.display = 'none';
    var ta = editor._textArea;
    var nc = editor._htmlArea.nextSibling;
    ta.parentNode.removeChild(ta);
    editor._htmlArea.parentNode.insertBefore(ta, nc);

It still works very well. I then follow this by some jQuery code to completely remove the editor:

    $(".htmlarea").remove();

This will leave you with just your textarea.

When you want to create (or move) the editor somewhere else, you can just run the same xinha_init function (or a different one, depending upon your setup) that you ran the first time.

It might seem a little drastic, but the method of nuke and recreate has been a little more reliable for me smile

Last edited by Practicality (2007-12-19 16:15:08)

Offline

Board footer

Powered by FluxBB