dojo如何在tabContainer中应用其他函数onClose事件?
我正在研究Tabcontainer。dojo是一种用于onClose事件将确认()的方法。我不使用confirm()我使用的w2confirm不适用。尝试了各种方法,但都没有成功。请帮帮我 dojo示例dojo如何在tabContainer中应用其他函数onClose事件?,dojo,w2ui,Dojo,W2ui,我正在研究Tabcontainer。dojo是一种用于onClose事件将确认()的方法。我不使用confirm()我使用的w2confirm不适用。尝试了各种方法,但都没有成功。请帮帮我 dojo示例 var closablePane = new ContentPane({ title:"Close Me", closable: true, onClose: function(){ // confirm() returns true or false,
var closablePane = new ContentPane({
title:"Close Me",
closable: true,
onClose: function(){
// confirm() returns true or false, so return that.
return confirm("Do you really want to Close this?");
}
});
onCloseEx.addChild(closablePane);
我的代码
function abc(){
w2confirm("are you delete?",function btn(ans){
if(ans=="Yes"){
return true;//this.close();
//console.log(registry.byId(id));
//registry.byId(id).close();
}else{
return false;
}
});
}
var tab = new dijit.layout.ContentPane({
title : name,
id : id,
content : content,
class : 'tab',
closable : true,
onClose : function() {
return abc();
}
});
var container = dijit.byId('tabContainer');
container.addChild(tab);
container.selectChild(tab);
w2confirm
没有有意义的返回值,因为它是异步运行的(因此您传递给它的回调),这意味着您的函数将在用户选择是或否之前返回
看起来您已经尝试了不同的方法,这是正确的,但是ContentPanes没有close
方法。不过,您可以做的是指示父TabContainer删除子项,然后销毁它。下面是一种可能的方法:
var tab = new dijit.layout.ContentPane({
...
onClose: function () {
w2confirm("Are you sure you want to delete?", function (answer) {
if (answer === "Yes") {
tab.getParent().removeChild(tab);
tab.destroyRecursive();
}
});
}
});