Dojo如何在TabContainer中应用OnClose事件的其他函数?
题
我正在研究tabContainer.Dojo是用于onClose事件的方法将确认()。我不使用确认()我使用的W2Confirm不适用。以各种方式尝试,但它没有工作。plz帮助我!
dojo示例
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
没有有意义的返回值,因为它异步操作(因此您传递给它),这意味着在用户选择是或否之前,您的功能将返回。
看起来你已经尝试了一种不同的方法,它在正确的轨道上,但ConteTyPanes没有生成的方法方法。但是,您可以做些什么,指示父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();
}
});
}
});
. 不隶属于 StackOverflow