事件“按下"在 sap.m.CustomListItem 上不起作用 [英] Event "press" on sap.m.CustomListItem doesn't work
问题描述
sap.m.CustomListItem 的 文档 表示 CustomListItem 有一个 press
事件.
The dokumentation of sap.m.CustomListItem says that CustomListItem hat a press
event.
我创建了一个站点,其中包含列表项上的按下事件,以及列表项内的 Button 上的另一个按下事件.该按钮工作正常.单击列表项不显示任何内容.甚至没有错误.
I created a site with the press event on a list item, and another press event on a Button inside the list item. The button works fine. A click on the list item shows nothing. Not even an error.
var oCustomItem = new sap.m.CustomListItem({
content: [
new sap.m.Text({
text: "{text}"}),
new sap.m.Button({
text: "btn",
press: function(){
alert("Pressed the button");
}
})
],
press: function(){
alert("Clicked the list item");
}
});
这是一个例子:http://jsbin.com/pozeve/4/edit?html,output
推荐答案
这是人们在使用 List 控件时经常遇到的问题.这里有一个答案.
This is a frequent issue people face when they´re using List controls. There´s an answer to this here.
简而言之,您要么必须将 type
属性添加到您的 CustomListItem
:
To put it in a nutshell, you either have to add a type
property to your CustomListItem
:
var oCustomItem = new sap.m.CustomListItem({
content: [
new sap.m.Text({
text: "{text}"}),
new sap.m.Button({
text: "btn",
press: function(){
alert("Pressed the button");
}
})
],
type : sap.m.ListType.Active,
press: function(){
alert("Clicked the list item");
}
});
或 mode
属性到您的 sap.m.List
.有关比较,请参阅上面提到的答案.
or a mode
property to your sap.m.List
. For a comparison see the answer mentioned above.
这篇关于事件“按下"在 sap.m.CustomListItem 上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!