0

I have a kind called RobustList, which extends Control, and it has these components:

components: [
    {name: "outerScroll",kind: "Scroller",touch: true,classes: "enyo-fit",components: [
            {name: "list",kind: "Repeater",onSetupItem: "setupItem",components: [
                    {name: "item",components: [
                            {name: "index",style: "display:none;"}
                    ]}, 
                    {name: "empty",fit: true,content: ""}, 
                    {name: "loadmore",fit: true,content: "Load More Items"}
                ]}
        ]}

]

Now I am catching the onSetupItem event, and in that function I am trying to access the children component. I am having a problem though. I was under the assumption that saying this.$ gave me access to all of the children component. Its currently only giving me access to outerscroll and list. Why is that?

Edit


Ok so apparently when using the List kind I can access all the children components (specifically in the create enyo function I am overriding). I'm very confused as to when its appropriate to do certain things. Like I assumed this.$ could be used everywhere. This is definitely not the case.

4

2 回答 2

3

this.$.在回答您的问题时,是的,如果它是一个列表,您可以使用 onSetupItem 中的任何 RobustList 子级访问它。在此处查看文档: https ://github.com/enyojs/enyo/wiki/Lists 。由于它的享元模式,List 中只有一组活动控件,因此您可以直接按名称引用它们。

您不希望使用this.$.来访问中继器中的项目,因为组件有许多副本(每行一个)。使用传入的引用(例如 var item = inEvent.item;)来访问行模板中的项目。

我还注意到您在列表中的几个组件上使用了“fit: true”。FittableColumn/FittableRow 中只能有一个 fit: true 组件。这些实际上都不是适合的,所以它可能不会做你想要的。

于 2013-09-05T22:42:49.800 回答
0
setupItem:function(inSender,inEvent){
    var data = this.data;
    if(data){
        var item = inEvent.item;
        var row = data[inEvent.index];
        item.$.loadmore.set('content',row.content);
    }
},
于 2016-03-07T08:52:13.087 回答