未触发带参数的按钮按下事件
Button press event with parameter not fired
我正在使用 xml 视图 (Form.view.xml),其中有一个提交按钮:
<mvc:View controllerName="articleIntroductionmdg.article.controller.Form" xmlns:mvc="sap.ui.core.mvc" xmlns:l="sap.ui.layout"
xmlns:f="sap.ui.layout.form" displayBlock="true" xmlns:core="sap.ui.core" xmlns:u="sap.ui.unified" xmlns="sap.m">
<Page busy="{local>/busy}">
<headerContent>
<Text text="{path: 'local>/vendorName', formatter: '.formatter.getUser'}"/>
<Button icon="sap-icon://customer"/>
</headerContent>
<Button type="Emphasized" text="{i18n>SubmitBtn}" press=".onSubmit($event, 'true')"></Button>
The event handler 'onSubmit' is defined in the controller:
onSubmit: function (oStatus) {
if ((oStatus) !== "false") {
this._validateForm();
}
}
我正在从控制器文件夹下的另一个 'common.js' 文件调用相同的 'onSubmit',它工作正常:
onUploadCSV: function () {
this.onSubmit("false");
}
但是当我尝试按下 Form.view.xml 的按钮时,
即使它自己也不会触发。
我查看了 sapui5 文档,其中写道您可以将参数传递给按下事件,例如:
<Button text="click" tap=".callFunction($event, 'mycustomString')" />
但我的情况是,视图中的事件没有#t 触发,我在控制台中没有收到任何消息。
从 1.56 版本开始首次支持在视图中将参数传递给控制器函数(可能您使用的是旧版本):https://sapui5.hana.ondemand.com/#/topic/53b4b5ec2c83408a8da2cb6b9154c246
我正在使用 xml 视图 (Form.view.xml),其中有一个提交按钮:
<mvc:View controllerName="articleIntroductionmdg.article.controller.Form" xmlns:mvc="sap.ui.core.mvc" xmlns:l="sap.ui.layout"
xmlns:f="sap.ui.layout.form" displayBlock="true" xmlns:core="sap.ui.core" xmlns:u="sap.ui.unified" xmlns="sap.m">
<Page busy="{local>/busy}">
<headerContent>
<Text text="{path: 'local>/vendorName', formatter: '.formatter.getUser'}"/>
<Button icon="sap-icon://customer"/>
</headerContent>
<Button type="Emphasized" text="{i18n>SubmitBtn}" press=".onSubmit($event, 'true')"></Button>
The event handler 'onSubmit' is defined in the controller:
onSubmit: function (oStatus) {
if ((oStatus) !== "false") {
this._validateForm();
}
}
我正在从控制器文件夹下的另一个 'common.js' 文件调用相同的 'onSubmit',它工作正常:
onUploadCSV: function () {
this.onSubmit("false");
}
但是当我尝试按下 Form.view.xml 的按钮时,
即使它自己也不会触发。
我查看了 sapui5 文档,其中写道您可以将参数传递给按下事件,例如:
<Button text="click" tap=".callFunction($event, 'mycustomString')" />
但我的情况是,视图中的事件没有#t 触发,我在控制台中没有收到任何消息。
从 1.56 版本开始首次支持在视图中将参数传递给控制器函数(可能您使用的是旧版本):https://sapui5.hana.ondemand.com/#/topic/53b4b5ec2c83408a8da2cb6b9154c246