Announcement

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

#1 2007-04-05 11:23:50

Chuck
Xinha Community Member
Registered: 2005-02-25
Posts: 29

Hook to a "xinha loaded" event

Is there a way to hook some code to run once the xinha editor is completely loaded?

I'm using xinha on a page where the french and english version of a text overlap in a tabbed layout but if I hide the 2nd editor before it's done loading, it won't display again (only in firefox) once I try to show it. I overcome this with a delay to my hiding code but that delay isn't constant and depends alot on the connection and the network load so I'd like to hook that hiding code to an event when xinha is done loading. I quickly checked the code and haven't found what I was looking for.

Any help on this one?

Offline

#2 2007-04-06 12:37:57

tissatussa
New member
From: Holland
Registered: 2007-04-05
Posts: 4

Re: Hook to a "xinha loaded" event

Hi,

I just had the same problem, and I DID find a solution on this forum : search for "_iframeLoadDone", that property was working for me, and I adjusted some scripting. Do something like this :


1) First make 'display' not 'none' for all Xinha editors on your page, or they can not be initialised by the Xinha scripting.



2) After your page is loaded (..?!) you execute some function by

window.onload = *somefunction*;
// the javascript onload function is NOT reliable : some things might NOT be fully loaded after this event, like the Xinha editor initialisation .. so we must develop a workaround ...

Here are two commands in the *somefunction* :

xinha_init(); // (from the Xinha scripting)
// here the Xinha editors are made and started, but they seem not fully ready after this command, although you might suspect such javascript behaviour ...

xinhaTimer = window.setTimeout('initDisplay()',*delay1 in ms*);
// directly coding initDisplay() does not work ?!
// BTW. i use delay1 1000 ms and even with my dad's internet connection (an old ISDN) no error occurs and the display of all Xinha editors is correctly initialised.



3) here is the initDisplay function :

var xinhaTimer;

function initDisplay()
    {
    for (var i=0;i < *number of editors*;i++)
        {
        if (!xinha_editors[*id*]._iframeLoadDone) // xinha_editors not totally ready ... ?!
            {
            // ... try it again after some time :
            xinhaTimer = window.setTimeout("initDisplay()",*delay2 in ms*);
            // here i use delay2 50 ms
            return false;
            }
        }

    window.clearTimeout(xinhaTimer); // xinha_editors all ready

    // ...
    // now hide the Xinha editor(s) you want, by display is none : that's it !

    }


HTH,
Roelof


simple is not always best, but best is always simple

Offline

#3 2007-04-10 10:29:33

Chuck
Xinha Community Member
Registered: 2005-02-25
Posts: 29

Re: Hook to a "xinha loaded" event

_iframeLoadDone did the trick perfectly, thanks alot tissatussa.

Using that variable for the checks, any delay does indeed work and has nothing to do with the connection speed. My delay was a simple timer hiding the xinha editor after a time, not checking it's loaded status.

Offline

Board footer

Powered by FluxBB