2

I was just trying to fire an event after the qooxdoo application is ready, so I started with the "Hello World" app and appended the recommendation at the very end of the main function:

 main : function(){ 
         // Hello World part...

    qx.event.Registration.addListener(window, "ready", function() { alert("application ready"); });
 }

but, it didn't appear to fire in chrome or firefox (I didn't test IE), so I dug some more and found this and it worked.

if (qx && qx.event && qx.event.Registration)
{
  var manager = qx.event.Registration.getManager(window);
  var handler = manager.findHandler(window, "ready");

  if (handler.isApplicationReady()) {
    alert("application ready");
  }
}

Can anyone tell my why the recommended method does not work or am I putting it in the wrong place?

Thanks!

Jonathan
  • 894
  • 2
  • 9
  • 20

3 Answers3

1

Did you get the "recommendation" from the "From jquery to qooxdoo" document?! (It always helps if you cite your sources).

I think you are mixing things here. First, "window ready" is not the same as "application ready". I think "window ready" (as shown in a linked manual page) is a low-level event of the global JS window object. If you are running a high-level qooxdoo application (as it appears) this event has long passed when you register for it in your main method. So the event handler is never run.

In your second code sample you are not listening for an event, but checking a status with isApplicationReady(). This status can return true long after the event that turned the app from non-ready to ready has passed.

ThomasH
  • 22,276
  • 13
  • 61
  • 62
  • Yes, that is where I found the reference. I will remember to include that next time. Ok, your explanation makes sense. I didn't realize that qooxdoo comes in after the window ready event. So, does isApplicationReady() fire after all the qooxdoo has run? I'm essentially looking to fire off an event after qooxdoo is ready and loaded. – Jonathan Feb 28 '12 at 17:43
  • Again, *isApplicationReady* is **not** an event firing, but a status check. As for your question, it really depends what you mean with "qooxdoo is ready and loaded". There is the "ready" event on window, but as you've seen it is fired before any of your custom code is run. - What do want this event for? When your main() code runs, you can be sure everything is ready and loaded. If you want to signal that to some other part of your application, you could fire a custom event!? – ThomasH Feb 29 '12 at 18:04
0

override simply the finalize function in the member area of the Application

finalize : function()
{
    // Call super class
    this.base(arguments);
    alert("Hello World");
}
0

More simple!!!

QX Core Widget "appear" event is equal the same as "onReady" event such in other JS Frameworks like YUI, JQuery or whatever....

http://www.qooxdoo.org/5.0.2/api/#qx.ui.core.Widget~appear!event

has the same effect.

best, Tamer

SmileMZ
  • 519
  • 5
  • 13