SAPUI5 (SPS 10)的SAPUI5开发人员指南(SPS 10)在"1.2.2.3.2向视图中添加控件“中解释了如何将侦听器添加到Button (JS视图):
var aControls = [];
var oButton = new sap.ui.commons.Button({
id : this.createId("MyButton"),
text : "Hello JS View"
});
aControls.push(oButton.attachPress(oController.doIt));
return aControls;以及如何实现控制器:
doIt : function(oEvent) { alert(oEvent.getSource().getId() + " does it!"); } 不幸的是,代码在我们的系统中不起作用(SAP HANA SPS 09)
是使用MVC (不是模型、视图、控制在一个文件中)的正确代码?
在哪里可以获得正确的开发人员信息?
发布于 2015-08-11 14:27:39
还可以在按钮声明中直接添加均衡器:
new sap.m.Button("button12345", {
text : "call function"
press : oController.myTestFunction
});发布于 2015-08-11 12:59:27
我想出了如何将侦听器添加到一个按钮中,注意MVC的概念:
查看:
createContent : function(oController) {
var btn = new sap.m.Button("button12345", { text : "call function" });
btn.attachPress(null, oController.myTestFunction, null);
return new sap.m.Page({
title : "Title",
content : [btn]
});
}主计长:
myTestFunction : function() { alert("Successfully called the test function");}https://stackoverflow.com/questions/31942518
复制相似问题