I’m trying to override the window.confirm in ExtJS 4. The override should return either true or false (just like confirm but with great UI).
window.confirm=function(msg) {var val=Ext.create("Ext.Window",{
title : 'Extra window!',
width : 150,
height: 100,
closable : true,
html : msg,
modal : true,
onEsc:aa,
items:[
{
xtype:'button',
text:'Ok',
handler:function()
{
return true;
}
},
{
xtype:'button',
text:'Cancel',
handler:function(){
return false;
}
}
]
}).show();
function aa(btn)
{
return false;
}
I’m getting the modal window wherever I use confirm, but it’s not returning either true or false, its running asynchronously.
I tried with showModalDialog instead of confirm, this time too I’m not getting return value.
Is it possible to return true or false based on user selection (when user selects ok then return true, false when clicking cancel)
You cannot call modal dialog in a sync fashion. If you want to wrap it somehow into utility function that you will call from different places in your application you need to do something like this: