tarini
29 May 2008, 2:35 AM
Hi guys, time to publish my little extension :)
I needed a custom-render confirmation message similar to Ext.MessageBox.confirm because I would have liked to render it (and being modal block user interactions) to a determinate container and not to my body.
So I created a custom Ext.Window (called ConfirmWindow) with this purpose.
Here's the code
Ext.namespace("Ext.ux");
Ext.ux.ConfirmWindow = Ext.extend(Ext.Window, {
yesIconCls: 'icon-yes',
noIconCls: 'icon-no',
yesText: 'Yes',
noText: 'No',
width: 250,
height: 100,
modal: true,
initComponent: function() {
this.bbar = ['->', {
handler: this.yesHandler,
scope: this,
iconCls: this.yesIconCls,
text: this.yesText
}, {
handler: this.noHandler,
scope: this,
iconCls: this.noIconCls,
text: this.noText
}];
this.items = new Ext.Panel({
html: this.message,
baseCls:'x-panel-mc',
bodyStyle: {paddingLeft: '5px', border: '0px'}
});
Ext.ux.ConfirmWindow.superclass.initComponent.call(this);
},
yesHandler: function() {
this.handler.call(this.scope);
this.close();
},
noHandler: function() {
this.close();
}
});
example of usage
var confirmWindow = new Ext.ux.ConfirmWindow({
title: "my title",
message: "my message",
handler: function() { doSomething() },
scope:this
});
confirmWindow.render(myContainer.getEl());
confirmWindow.show();
I write this code trying to be most conventional to Ext standard
If you get some problems or ideas, post here a message :)
I needed a custom-render confirmation message similar to Ext.MessageBox.confirm because I would have liked to render it (and being modal block user interactions) to a determinate container and not to my body.
So I created a custom Ext.Window (called ConfirmWindow) with this purpose.
Here's the code
Ext.namespace("Ext.ux");
Ext.ux.ConfirmWindow = Ext.extend(Ext.Window, {
yesIconCls: 'icon-yes',
noIconCls: 'icon-no',
yesText: 'Yes',
noText: 'No',
width: 250,
height: 100,
modal: true,
initComponent: function() {
this.bbar = ['->', {
handler: this.yesHandler,
scope: this,
iconCls: this.yesIconCls,
text: this.yesText
}, {
handler: this.noHandler,
scope: this,
iconCls: this.noIconCls,
text: this.noText
}];
this.items = new Ext.Panel({
html: this.message,
baseCls:'x-panel-mc',
bodyStyle: {paddingLeft: '5px', border: '0px'}
});
Ext.ux.ConfirmWindow.superclass.initComponent.call(this);
},
yesHandler: function() {
this.handler.call(this.scope);
this.close();
},
noHandler: function() {
this.close();
}
});
example of usage
var confirmWindow = new Ext.ux.ConfirmWindow({
title: "my title",
message: "my message",
handler: function() { doSomething() },
scope:this
});
confirmWindow.render(myContainer.getEl());
confirmWindow.show();
I write this code trying to be most conventional to Ext standard
If you get some problems or ideas, post here a message :)