Skip to Content
0
Former Member
Jun 07, 2015 at 07:20 AM

How to access the object passed along with the event object in the fireBuy() method?

18 Views

<script>
sap.ui.core.Control.extend("com.controls.MyButton", {
metadata: {
aggregations: {
buyButton : { type: "sap.ui.commons.Button", multiple: false}
},
events: {
buy: {enablePreventDefault: true}
}
},
init: function() {
var oControl = this;
//create a button to allow used buying that book
var oBuyBtn = new sap.ui.commons.Button({
text: "Click Me",
press: function (oEvent) {
oControl.fireBuy({
someData : "some data I want to pass along with the event object"
});
}
});
this.setAggregation("buyButton", oBuyBtn);

},
renderer: {
render: function(oRm, oControl) {
oRm.renderControl(oControl.getAggregation("buyButton"));
}
}
});

var oButton = new com.controls.MyButton({
buy: function(oEvent) {
alert(oEvent.someData);
}
});
oButton.placeAt("content");

</script>


The code is shown above. I want to get the someData property in the change callback function, How can I possibly achieve that? I tried oEvent.someData, but I got undefined alert. The code is from nabisoft website, but there has no explanation on how to access the object passed by the fireBuy method.

Attachments

ask.jpg (51.1 kB)