In lieu of a better (tapestry provided) solution, this is what i'm using. It seems to work, but I can see the need to make the callbacks parameterised in the future (which currently isn't supported by Tapestry.onDOMLoaded)

function callWhenPageLoaded(callback)
{
    if (typeof(Tapestry) == "undefined")
        throw("callWhenPageLoaded called too early");

    if (Tapestry.pageLoaded)
        callback.call(this);
    else
        Tapestry.onDOMLoaded(callback);
}

If something like this doesn't exist in tapestry already, I think it should.

p.

On 7/03/2011 9:44 AM, Paul Stanton wrote:
Hi all,

i'm using tapestry 5.1.0.5 on this particular project.

I'm not 100% sure this isn't already available, but before duplicating logic i thought I'd check...

I need to be able to call a function at any point in the page state (ie before it's loaded, during loading, after load) but have it wait until tapestry.init has been called.

Kind of how Tapestry.waitForPage works, except that if the page has not loaded, instead of showing a dialog, it would register it for invoking once the page is loaded.

so in psuedo:

function(callback)
{
    if(Tapestry.pageLoaded)
        invoke(callback);
    else
        Tapestry.onDOMLoaded(callback);
}

2 questions:
a) is this functionality already available? where?
b) would the above approach be fool-proof? ie would there be a case where Tapestry.pageLoaded == false and Tapestry.onDOMLoaded would still not invoke the callback?

thanks, p.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to