PDA

View Full Version : Ext.Msg.show animEl twice in a row.



yziquel
17 Sep 2009, 7:04 PM
Hello.

I've been trying to execute

new Ext.Msg.show({
animEl: 'thisdiv',
.......
})

twice in a row. The first time, it works fine. The second time, the whole message box disappears. I'm on Firefox 3.5.2.

mitchellsimoens
17 Sep 2009, 7:17 PM
In the API under Ext->MessageBox->show() it states:


Displays a new message box, or reinitializes an existing message box...

So can it actually have more than one?

yziquel
18 Sep 2009, 3:04 AM
No it cannot have more than one, and I want the second instance to replace the first instance. I'm using a background manager to query the server at regular intervals, that's the idea.

The thing, it replaces fine when NOT using animateEl, but doesn't work when using animateEl. Even when hide()ing it before replacing. That's an issue for me.

Animal
18 Sep 2009, 3:51 AM
When you say "twice in a row", what does that mean?

Because it does work, you can show the MsgBox as many times as you like.

yziquel
18 Sep 2009, 4:32 AM
I mean, at time t=0, do an Ext.Msg.show with animateEl: 'mydiv'.

Message box shows.

At time t = "10 seconds later", do the same piece of code.

Then the first message box disappears without any animation, and I do not see a Message box on the screen. Nor the first MessageBox, nor the second MessageBox.

That's the server-side chunk of code:

Ext.onReady(function() {

var background_task = {
run: function(){
Ext.Ajax.request({
url: '/updateagent/"^suffix^"',
success: function(objServerResponse){
var server_update = Ext.util.JSON.decode(objServerResponse.responseText);
if (server_update.type = \"calling\") {
Ext.Msg.show({
title: 'Actuellement en appel',
msg: '<p>'+server_update.number+'<p>',
animEl: 'webapp',
closable: false,
modal: false
})
}
},
failure: function(objServerResponse){
}
});
},
interval: 2000
};
Ext.TaskMgr.start(background_task);

});

Animal
18 Sep 2009, 4:36 AM
Can't read that code. Follow posting guidelines.

yziquel
18 Sep 2009, 4:50 AM
Here it is:




Ext.onReady(function() {

var background_task = {
run: function(){
Ext.Ajax.request({
url: '/updateagent/"^suffix^"',
success: function(objServerResponse){
var server_update = Ext.util.JSON.decode(objServerResponse.responseText);
if (server_update.type = \"calling\") {
Ext.Msg.show({
title: 'Actuellement en appel',
msg: '<p>'+server_update.number+'<p>',
animEl: 'webapp',
closable: false,
modal: false
})
}
},
failure: function(objServerResponse){
}
});
},
interval: 2000
};
Ext.TaskMgr.start(background_task);

Animal
18 Sep 2009, 4:53 AM
Don't use animEl if they are going to be that frequent. Each show will interfere with the last.

Animal
18 Sep 2009, 4:54 AM
Anyway, that's not a suitable method. If you are going to be repeatedly doing something every 2 seconds, you don't want a message box showing up.

You need some dedicated logging Panel in your app.

yziquel
18 Sep 2009, 5:02 AM
They are not that frequent. It is the purpose of the server_update.type to trigger the show(). So it polls every 2 secs, but doesn't react every two secs.

By the way, I want to have a dialog box popping up this way. And it works fine without the animEl tag. That's my issue.

Animal
18 Sep 2009, 5:16 AM
And that's the problem. It takes a while for it to both show and hide.

So it hides (animating as it does so) before every show. That takes a while. So meanwhile, show is being called which animates the show.

It's just not suitable.

yziquel
18 Sep 2009, 5:18 AM
OK. So perhaps a hide(), with a callback, which then show()s?

Animal
18 Sep 2009, 9:51 AM
Are you sure that's a good pattern? So on return from Ajax it pops up. Then when does it hide? And when it's hidden, you sure you want this thing regularly popping up regardless of what other stuff the user is doing?

yziquel
18 Sep 2009, 10:32 AM
I've got an Asterisk server, connected to a VoIP service provider. There's a bunch of code code in Objective Caml that connects to the Asterisk server through a socket. This bunch of code is dynamically loaded at server startup (the server is Ocsigen). The server then serves Ext-based pages to an administrator (administrative interface) and to the unprivileged users, i.e. agents, who are supposed to answer calls without having to pick up the phone. So when a phone call occurs, a dialog needs to pop up. When the call ends, the dialog is modified for the user to enter some feedback, and then is closed. When another call comes in, the user gets a dialog. So the whole idea is for the unprivileged user to have as little control over the beast. If the user is doing something else, then I'll have to look into when making to message box pop up with as little bother on the user side, but is not something the user should control. The server should control this, as it controls the whole dialing process.

Is that a clear enough description of my use case?

Animal
18 Sep 2009, 10:39 AM
Yes. I'd say you should write a UI class to handle this special and complex case, and not rely on the MessageBox singleton.