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.
Use Promise for callbacks.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
see below code
fnConfirmationMsg: function(sMessage, sConfirmation) {
return new Promise((fnResolve, fnReject ) => {
MessageBox.show( sMessage, {
title: sConfirmation,
onClose: fnResolve
}
);
});
};
deleteRecord: function(oData) {
this.fnConfirmationMsg("Delete data?", "Delete confirmation").then((sAction)=>{
switch(oAction) {
case "OK":
/* do delete operation */
break;
default:
break;
})
};
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| 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.