onyx.Checkbox in an enyo.List

I was having an issue getting the checkbox to work properly, if at all, in an enyo.List. I simply could not do it. So I came up with the following, and I would appreciate any suggestions or improvements:

fiddle: http://jsfiddle.net/znibble/6tzLB/

enyo.kind({
    name: "selectOnHold",
    kind: "Control",
    components: [{
        kind: "onyx.Checkbox",
        name: "checkbox",
        classes: "list-sample-index",
    }],
    handlers: {
        onchange: ""
    }
})

enyo.kind({
    name: "mainPanels",
    kind: "FittableRows",
    classes: "onyx enyo-fit",

    components: [
{
        kind: "Panels",
        fit: true,
        classes: "panels-sample-sliding-panels",
        arrangerKind: "CollapsingArranger",
        wrap: false,
        components: [{
            name: "middle",
            fit: true,
            components: [{
                kind: "List",
                name: "list",
                classes: "enyo-fit",
                touch: true,
                onSetupItem: "setupItem",
                count: 20,
                components: [{
                    kind: "selectOnHold"
                }, {
                    name: "rowItem",
                    classes: "panels-sample-sliding-item",
                    ontap: "listitemTapped",
                }]
            }]
        }]
    }],
    handlers: {
        onchange: "checkEvt"
    },
    create: function () {
        this.inherited(arguments);
        this.toggle = [];
    },
    setupItem: function (inSender, inEvent) {       
this.$.selectOnHold.$.check.setChecked(this.toggle[inEvent.index]);
     this.$.rowItem.setContent("list row");                                        
        return true;
    },
    listitemTapped: function (inSender, inEvent) {
        //event for tapping list item, not checkbox
    },
    checkEvt: function (inSender, inEvent) {
        this.toggle[inEvent.index] = !this.toggle[inEvent.index];
        this.$.list.renderRow(inEvent.index)
    },
});

Comments

Sign In or Register to comment.