on 10-15-2015 8:34 AM
Hi everyone.
The following code works:
var oDialog = new sap.ui.commons.Dialog();
oButton = new sap.ui.commons.Button();
oButton.setText("Close");
oButton.attachPress(HandleButtonClick);
oDialog.addButton(oButton);
// Open Dialog
oDialog.open();
function HandleButtonClick()
{ oDialog.close(); }
But this doesn't. Basically I'm trying to pass reference of oDialog, so that I can close it at a later stage.
var oDialog = new sap.ui.commons.Dialog();
oButton = new sap.ui.commons.Button();
oButton.setText("Close");
oButton.attachPress(HandleButtonClick(oDialog));
oDialog.addButton(oButton);
// Open Dialog
oDialog.open();
function HandleButtonClick(oDialog)
{ oDialog.close(); }
Thanks in advance guys.
Hi,
Try using the following code:
var oDialog = new sap.ui.commons.Dialog();
oButton = new sap.ui.commons.Button({
text: "Close",
press: HandleButtonClick({dialog: oDialog})
});
oDialog.addButton(oButton);
//Open Dialog
oDialog.open();
function HandleButtonClick(oEvent){
var dialog = oEvent.getParameter("dialog");
oDialog.close();
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your response. I'm getting a "Object doesn't support property or method 'getParameter' " error. I have modified my code as below:
oButton = new sap.ui.commons.Button();
oButton.setText("Close");
oButton.attachPress(HandleButtonClick({dialog: oDialog}));
oDialog.addButton(oButton);
// Open Dialog
oDialog.open();
function HandleButtonClick(oEvent)
{ var Dialog = oEvent.getParameter("dialog");
Dialog.close();
}
Thanks
Hi, yea I didn't test the code before I posted that... Sorry for that.
Take a look at the jsbin: https://jsbin.com/vinusub/edit?html,js,output
For if jsbin doesn't work for some reason:
var oDialog = new sap.ui.commons.Dialog();
oButton = new sap.ui.commons.Button();
oButton.setText("Close");
oButton.attachPress(function(oEvent){HandleButtonClick(oDialog);});
oDialog.addButton(oButton);
//Open Dialog
var open = new sap.ui.commons.Button({
text:"Open dialog",
press: function(){oDialog.open();}
});
function HandleButtonClick(oDialog){
oDialog.close();
}
So I found another way of passing data along, I think this should be the preferred method:
var oDialog = new sap.ui.commons.Dialog();
function HandleButtonClick(oEvent, data)
{
var Dialog = data.dialog;
Dialog.close();
}
oButton = new sap.ui.commons.Button();
oButton.setText("Close");
oButton.attachPress({dialog: oDialog}, HandleButtonClick);
oDialog.addButton(oButton);
The jsbin link, it sends multiple data items to the function: JS Bin - Collaborative JavaScript Debugging
The documentation of attachPress shows that you can include custom Data using this method: JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.commons.Button
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.