I am studying the Tabcontainer.The dojo is a method used to onClose event will confirm (). I do not use the confirm () the w2confirm I use does not apply. Attempted in various ways, but it did not work. plz help me!
dojo example
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);
my code
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
does not have a meaningful return value because it operates asynchronously (hence the callback you pass to it), which means that your function is going to return before the user ever chooses yes or no.
It looks like you already attempted a different approach, which was on the right track, but ContentPanes don't have a close
method. What you can do, though, is instruct the parent TabContainer to remove the child, then destroy it. Here's a potential way to do it:
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();
}
});
}
});