on 08-10-2015 10:16 AM
hi i am trying to display a message box and based on action on message box it should undergo the condition.
jQuery.sap.require("sap.m.MessageBox");
sap.m.MessageBox.show(
"Please Confirm to Submit", {
icon: sap.m.MessageBox.Icon.INFORMATION,
title: "Dear User",
actions: [sap.m.MessageBox.Action.YES, sap.m.MessageBox.Action.NO],
onClose: function(oAction){
if(oAction == "YES"){var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
oRouter.navTo('default');}
},
}
);
here i am trying to navigate to another view if i select YES button in message box.but it is not happening.can u help where i went wrong?
I think it should be
jQuery.sap.require("sap.m.MessageBox");
sap.m.MessageBox.show("Please Confirm to Submit", {
icon: sap.m.MessageBox.Icon.INFORMATION,
title: "Dear User",
actions: [sap.m.MessageBox.Action.YES, sap.m.MessageBox.Action.NO],
onClose: function(oAction) {
if (oAction == "YES") {
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
oRouter.navTo('default');
}
}.bind(this)
});
Thanks
-D
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I feel this answer needs a lot more likes...
This is the correct answer.
To expand, the reason the original poster's code didn't want to work, is that he was trying to reference "this" within the Callback function of the MessageBox, which, in the callback instance, refers to the MessageBox, and NOT the View as the OP seemed to have thought.
Once the "View's this" is bound to the MessageBox, the Callback Function can now refer to that object in it's Async "thread", and can access functions/attributes of the View, like this.handleOnSave, or getRouter(this).
Thanks to for this answer, it has saved me hours of trying to work around ASYNC calls within the SAPUI5 framework.
if possible can anyone post an example in jsbin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please mark this Discussion with a Correct Answer (closes, but does not lock the Discussion) and Helpful Answer where appropriate. See http://scn.sap.com/community/support/blog/2013/04/03/how-to-close-a-discussion-and-why Even if you discovered the solution without any outside contributions, it helps others to understand what the solution turned out to be.
Do not use Assumed Answered as it confuses anyone looking for the specific answer. If you dig into the Getting Started link (top right of each SCN page), you are only instructed to mark Helpful or Correct Answers to Discussion responses.
Thanks, Mike (Moderator)
SAP Technology RIG
Hi Sunnel,
I don't see problem with your code. I have tested and i am able to close the message box.
Where exactly you are facing the issue.
Thanks,
Naga
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
try,
if (oAction === sap.m.MessageBox.Action.YES) {
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
See this example-
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.