0

I have the the repeater.js in which m getting the values on load.that is setupItem method..

I want to get the same value on click of an button..This problem m getting in case of both list and repeater...data are loading onload but on button its not working...can anyone help....

enyo.kind({
    name: "enyo.sample.RepeaterSample",
    classes: "enyo-fit repeater-sample",
    components: [
        {kind: "Repeater", onSetupItem:"setupItem", components: [
            {name:"item", classes:"repeater-sample-item", components: [
                {tag:"span", name: "personNumber"},
                {tag:"span", name: "personName"}
            ]}
        ]},
        //{kind: "onyx.Button", content:"Fetch", ontap:"setupItem"}
    ],
    create: function() {
        this.inherited(arguments);
        this.$.repeater.setCount(this.people.length);
        this.peopleChanged();
    },
    published: {
        people: []
    },
    peopleChanged: function() {
        for(var i=0;i < 5;i++){
            this.people[i]="art "+i;
        }
        this.$.repeater.setCount(this.people.length);
    },
    setupItem: function(inSender, inEvent) {
        var index = inEvent.index;
        var item = inEvent.item;
        alert(this.people[index]);
        var person = this.people[index];
        //item.$.personNumber.setContent((index) + ". ");
        item.$.personName.setContent(person);
        //item.$.personName.applyStyle("color", person.sex == "male" ? "dodgerblue" :        "deeppink");
    },
});
Pre101
  • 2,370
  • 16
  • 23
Suchismita
  • 85
  • 12
  • y dont you save the item in a global val and use it on click? – thecodejack Sep 07 '12 at 11:09
  • @CodeJack the list or the repeater kind are taking data only through method setupItem if m calling that through onSetupItem .if m removing this onSetupItem its not loading the data at all...i want to call the method like one custom method...... – Suchismita Sep 07 '12 at 11:29
  • i donno how enyo provides that functionality, but if you are not able to load data on button click thgh enyo, one way is you can load this repeater completely on button click rather than just data in repeater.... – thecodejack Sep 07 '12 at 11:35

1 Answers1

0

I think you may be confusing what needs to happen here. The setupItem method should only be called in response to the onSetupItem event that is thrown by the list when you .setCount() on it or .build() it.

So, the handler for ontap of your button should set the contents of the array, then either change the count on the list (with setCount()) or call .build() on it directly.

Webby Vanderhack
  • 889
  • 7
  • 13