I wonder if it is possible to bind an Event via a JSONModel.
If I do so, it will always throw this Exception:
Uncaught TypeError: I.fFunction.call is not a function
This is my code:
_ViewReference: undefined,
_oMenuItemsConfigModel: undefined,
createMenu: function(oItem){
if (!this._menu) {
this._menu = new sap.ui.unified.Menu(this._oMenuConfig);
this._menu.setModel(this._oMenuItemsConfigModel);
this._menu.bindAggregation("items", "/", new sap.ui.unified.MenuItem({
text: "{text}",
icon: "{icon}",
select: "{select}",
enabled: "{enabled}"
}));
this._ViewReference.addDependent(this._menu);
}
var eDock = sap.ui.core.Popup.Dock;
this._menu.open(false, oItem, eDock.BeginTop, eDock.BeginBottom, oItem);
return oItem;
}
I have a Universal ContextMenu which just needs some config in order to get created. This is how I call this function from my Controller:
var oContextMenu = new ContextMenu(this.getView(),
new sap.ui.model.json.JSONModel(
[
{
text: "Copy",
select: [this.onContextMenuItemCopySelected, this]
},
{
text: "Paste",
select: [this.onContextMenuItemPasteSelected, this]
}
]
)
);
Here is a JSBin Example.