Hello,
I am trying to create a function to delete data after user press delete button on MessageBox of confirmation.
I know that it will work following code;
MessageBox.confirm(
"Delete data?", {
title: "Delete confirmation",
onClose: function(oAction) {
switch(oAction) {
case "OK":
/* do delete operation */
break;
default:
break;
}
);
But, I want to know how to separate the callback function from the code of MessageBox as below, becasue this application needs post-processes after deletion so that the code will be longer, I think it should not be included in the code of calling MessageBox.
~~~~~~~
MessageBox.show(
"Delete data?", {
title: "Delete confirmation",
onClose: ".afterDeleteConfirmation"
);
~~~~~~
afterDeleteConfirmation: function(oAction) {
switch(oAction) {
case "OK":
/* do delete operation */
break;
default:
break;
}
Request clarification before answering.
You can create a separate function and call it from the callback. Use the reference of this but you need to assign it to another variable outside the messagebox function.
~~~~~~~
var that=this;
MessageBox.show(
"Delete data?", {
title: "Delete confirmation",
onClose: function(oAction){
that.afterDeleteConfirmation(oAction);
}
);
~~~~~~
afterDeleteConfirmation: function(oAction) {
switch(oAction) {
case "OK":
/* do delete operation */
break;
default:
break;
}Regards
Anmol
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
You can simplify it like this :
MessageBox.show(
"Delete data?", {
title: "Delete confirmation",
onClose: this.afterDeleteConfirmation.bind(this)
);
Regards,
Joseph
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.