PDA

View Full Version : MessageBox Not Closing



alphadogg
15 Apr 2010, 5:45 AM
I am new to ExtJS, so I am still wrapping my head around the whole library, but I have a starter's issue. I am displaying a MessageBox, but calling hide() won't hide it.

Basically, I have:


<body onload="CPOPExt.init();">
<div id="divSource"></div>
</body>
and



Ext.namespace("CPOPExt", "CPOPExt.UIObjects", "CPOPExt.UIEventHandlers", "CPOPExt.Data");

CPOPExt.init = function() {
// show initialization message
Ext.Msg.show({
title: "<span id='initTitle'>CPOP Intialization</span>",
msg: "<span id='initMsg'>Initializing complete rebuild of the Universe. Please stand by...</span>",
buttons: false,
closable: false,
animEl: "divSource",
icon: Ext.Msg.INFO
});

// startup tests

// kick off UI
CPOPExt.buildUI();

Ext.Msg.hide();

return;
};


Somehow, the MessageBox won't close. And, yes, I am reaching the end; a simple alert() call just before the return seems to display the standard Javascript alert.

What am I doing wrong?

Sgt.Pepper
15 Apr 2010, 6:18 AM
Don't know if this will change anything, but just to make sure. Try to kick of your application in the Ext.onReady function, not on the body load event:




Ext.onReady(function () {
CPOPExt.init()
})

15 Apr 2010, 6:35 AM
Yes, use Ext.onReady instead of body.onLoad

alphadogg
15 Apr 2010, 6:36 AM
I moved it out of the BODY tag and into the js file and it still didn't work. The box is simply not being closed. The alert() is coming up though, so we are reaching that hide() method call.



Ext.onReady(function() {
CPOPExt.init();
})

Ext.namespace("CPOPExt", "CPOPExt.UIObjects", "CPOPExt.UIEventHandlers", "CPOPExt.Data");

CPOPExt.init = function() {
// show initialization message
Ext.Msg.show({
title: "<span id='initTitle'>CPOP Intialization</span>",
msg: "<span id='initMsg'>Initializing complete rebuild of the Universe. Please stand by...</span>",
buttons: false,
closable: false,
animEl: "divSource",
icon: Ext.Msg.INFO
});

// startup tests

// kick off UI
CPOPExt.buildUI();

Ext.Msg.hide();
alert('done');
return;
};

alphadogg
15 Apr 2010, 8:17 PM
I've been beating my head against the wall here. Any other reason why I can't close a Ext.Msg?

Animal
15 Apr 2010, 9:17 PM
Think about it.

hide() only works if it's visible. The docs tell you that.

Animate showing takes a second or so to show it....

alphadogg
16 Apr 2010, 7:05 PM
Thanks, doing setTimeout("Ext.Msg.hide()", 2000) actually hides the message box and it is an asynchronous thing.

But, I hope there's a better way than guessing how long layout takes? :)

Animal
16 Apr 2010, 10:20 PM
I suggest not doing a show and IMMEDIATE hide! What's that all about????