[英]Execute synchronously MessageBox show function in ExtJs-5
I want to execute a Ext.Msg.show()
function synchronously in ExtJs-5我想在 ExtJs-5 中同步执行一个Ext.Msg.show()
function
onButtonClick : function() {
1. some code...
2. Ext.Msg.show({
title : 'Confirm Please',
msg : 'Please be informed that record will only save when click ok.',
buttons : Ext.Msg.OKCANCEL,
icon : Ext.Msg.QUESTION,
fn : function(btn) {
if ('cancel' === btn) {
return;
}
}
});
3. other message box ...
4. other code ...
}
The above function execute synchronously each step 1, 2, 3 & 4 but doesn't wait for user interaction on step 2. It directly move to step 3 and after that to step 4. But I want to execute step 3 only when user click on ok else terminate other below steps.上面的 function 同步执行每个步骤 1、2、3 和 4,但不等待用户在步骤 2 上进行交互。它直接转到步骤 3,然后转到步骤 4。但我只想在用户单击时执行步骤 3好的,否则终止其他以下步骤。
Can anybody check and let me know the possible code that I need to add to make it possible?任何人都可以检查并让我知道我需要添加以使其成为可能的可能代码吗? Thanks谢谢
There is an easier and integrated way to accomplish a confirm window: Ext.Msg.confirm .有一种更简单的集成方式来完成确认 window: Ext.Msg.confirm 。
Remember that a "confirm" in ExtJs is ASYNCHRONOUS compared to the one of pure javascript. So your step 3/4 should be moved to the btnId==yes condition block:请记住,与纯 javascript 中的“确认”相比,ExtJs 中的“确认”是异步的。因此,您的步骤 3/4 应移至btnId==yes条件块:
Below an example:下面是一个例子:
Ext.Msg.confirm("Confirm", "Are you sure?", function(btnId){
if(btnId == "yes"){
// User clicked YES
// Move here step 3/4
}
else {
// User clicked NO
}
});
Bonus Tip : nothing stops you from nesting a confirm in a confirm like this:额外提示:没有什么能阻止你像这样在确认中嵌套确认:
// Confirm #1
Ext.Msg.confirm("Confirm", "Are you sure?", function(btnId){
if(btnId == "yes"){
// User clicked YES
// Confirm #2
Ext.Msg.confirm("Confirm", "Are you REAAALLY sure?", function(btnId){
if(btnId == "yes"){
// User clicked YES
}
else {
// User clicked NO
}
});
}
else {
// User clicked NO
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.