PDA

View Full Version : Changing default postion of alert box



cpryce
31 Aug 2007, 11:16 AM
If I wanted all of my alert boxes to appear 100px from the top of the window, instead of the center of the screen, is that possible?

How would I go about doing that?

Animal
31 Aug 2007, 12:09 PM
Get the singleton BasicDialog.

http://extjs.com/deploy/ext/docs/output/Ext.MessageBox.html#getDialog

Set its fixedcenter property to false;

Add a listener to http://extjs.com/deploy/ext/docs/output/Ext.BasicDialog.html#event-beforeshow

To set the position you want using http://extjs.com/deploy/ext/docs/output/Ext.BasicDialog.html#moveTo or http://extjs.com/deploy/ext/docs/output/Ext.BasicDialog.html#alignTo

cpryce
31 Aug 2007, 12:57 PM
Get the singleton BasicDialog.

http://extjs.com/deploy/ext/docs/output/Ext.MessageBox.html#getDialog

Set its fixedcenter property to false;

Add a listener to http://extjs.com/deploy/ext/docs/output/Ext.BasicDialog.html#event-beforeshow

To set the position you want using http://extjs.com/deploy/ext/docs/output/Ext.BasicDialog.html#moveTo or http://extjs.com/deploy/ext/docs/output/Ext.BasicDialog.html#alignTo


Animal:

thanks for the response. I'm not sure that I follow it.

I'm using the MessageBox.alert in this fashion, in one of the handlers for a toolbar:



tb.add({
icon: '/eWeb/images/save.gif',
cls: 'x-btn-icon',
tooltip: 'Save Report',
handler: function() {

Ext.MessageBox.alert('Results', 'Report Data Saved');

},
tooltipType: 'title'
});


The docs say that MessageBox is a singleton and can't be directly created. So if I try some thing like:



var mb = new Ext.MessageBox({title:"Results", msg:"Data Saved"});
var basicDialog = mb.getDialog();



It of course raises an error. I looked at the examples, but they were not much help. Should I use BasicDialog directly instead?

Animal
31 Aug 2007, 1:07 PM
Ext.MessageBox is itself a singleton. It exists - you're already using it!.



var theOneAndOnlyMessageBox = Ext.MessageBox.getDialog();
theOneAndOnlyMessageBox.fixedcenter = false;
theOneAndOnlyMessageBox.on("beforeshow", function() {
theOneAndOnlyMessageBox.moveTo(0, 0);
});