Ext.MessageBox.show({
title:'Messagebox Title',
msg: 'Are you sure want to delete?',
buttons: {yes: "Some Button 1",no: "Some Button 2",cancel: "Some Button 3"}
});
ExtJS 4或4.1不支持此代码。按钮无法显示。
刚刚发现了如何做到这一点,希望能对某些人有所帮助。正如你所看到的,你可以随心所欲地处理这些按钮。请注意,框架默认只有4个按钮,并且这是一个不容易克服的限制。在源代码中,有多个循环硬编码从0到< 4。
Ext.MessageBox.show({
title:'Messagebox Title',
msg: 'Are you sure want to delete?',
buttonText: {yes: "Some Button 1",no: "Some Button 2",cancel: "Some Button 3"},
fn: function(btn){
console.debug('you clicked: ',btn); //you clicked: yes
}
});
你不能在show方法内这样做,因为该方法中的按钮配置需要一个标识要显示哪些按钮的数字作为参数。你可以预定义你的消息框,然后只需显示它即可。
var win = Ext.create('Ext.window.MessageBox', {
width:300,
height: 100,
buttons: [
{text: 'My button 1'},{
text: 'My button 2'}
]
});
win.show({
title:'Messagebox Title',
msg: 'Are you sure want to delete?',
icon: Ext.Msg.QUESTION
});
Ext.MessageBox.show({
title:'Messagebox Title',
msg: 'Are you sure want to delete?',
buttonText: {
yes: 'Some Button 1',
no: 'Some Button 2',
cancel: 'Some Button 3'
}
});
<script type="text/javascript">
(function () {
Ext.override(Ext.MessageBox, {
buttonText: { yes: "Sí", no: "No", cancel: "Cancelar" }
});
})();
</script>