Ext.setup({
onReady: function() {
var pnlMain = new Ext.Panel({
fullscreen: true,
html: 'This is an example',
dockedItems: [{
xtype: 'toolbar',
title: 'Example',
items: [{
text: 'Show PopUp',
handler: function(){
popup.show();
}
}]
}]
});
var popup = new Ext.Panel({
floating: true,
centered: true,
modal: true,
width: 300,
height: 400,
styleHtmlContent: true,
html: 'Hello! I\'m a PopUp',
dockedItems: [{
xtype: 'toolbar',
title: 'PopUp',
items: [{
xtype: 'spacer'
},{
text: 'Close',
handler: function(){
popup.hide();
}
}]
}]
});
}
});
This will show you a modal popup in the center of your screen.
If you want to attach the popup to the button taht open it just change the button handler in this way
handler: function(btn){
popup.showBy(btn);
}
原文: http://www.sencha.com/forum/showthread.php?122382-Can-I-have-a-quot-popup-quot-panel-opened-on-clicking-a-button