最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Event "press" on sap.m.CustomListItem doesn't work - Stack Overflow

programmeradmin0浏览0评论

The dokumentation of sap.m.CustomListItem says that CustomListItem hat a press event.

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");
    }
});

Here is an example: ,output

The dokumentation of sap.m.CustomListItem says that CustomListItem hat a press event.

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");
    }
});

Here is an example: http://jsbin./pozeve/4/edit?html,output

Share Improve this question asked Dec 17, 2014 at 12:13 DerZyklopDerZyklop 3,8232 gold badges22 silver badges28 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 4

This is a frequent issue people face when they´re using List controls. There´s an answer to this here.

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");
            }
});

or a mode property to your sap.m.List. For a parison see the answer mentioned above.

发布评论

评论列表(0)

  1. 暂无评论