0
enyo.kind({
    name: "Usr",
    kind: enyo.Control,

    published: {
        username: "",
        ToDo: [],
        Done:[]
    },

    components: [
        {tag:"title",name:"username"},
        {tag:"input", name:"desc", placeholder: "to do..", 
            style:"width:500px; static: left; padding-right: 10px"}, 
        {tag: "button", content: "New Task", ontap: "addTask", 
            style:"float: right; padding-left: 10px; 
            background-color:orange; color:white" },
        {tag: "div", name: "ToDo" }
    ],

    addTask: function(inSource, inEvent) {
        this.createComponent({
            kind: Task,
            container: this.$.ToDo,
            text: this.$.desc.hasNode().value,
            state: "To do"
        });
        this.$.ToDo.render();
    }
})

So, this is what i have. As you can see, I create new elements (Task kind is defined in other js file, doesn´t really matters) using (addTask) and putting them inside the ToDo "div" component. How can I iterate over those elements? something like a 'for each' sentence or so, maybe is there a $'div'.length property or something? I haven´t found an answer in any official documentation.

  • My personal affinity is to create an enyo.Collection (basically an array with a lot of extra features) of enyo.Models (your data) when I'm dealing with multiple similar things. You should be able to easily iterate the collection (collection.each or collection.map, one of those) and do the things you like. – Webby Vanderhack Jul 17 '16 at 20:10
  • I would echo what Dave said. Make your todo div into a `DataList` and add a new model to your collection. It would be a cleaner way to do it. If you're iterating over your children to find things you may be 'doing it wrong'. – Pre101 Jul 17 '16 at 22:48

0 Answers0