Skip to content

nested $repeats and $index values #70

@Joera

Description

@Joera

Question: Who has an idea how i can get a parent $index value inside a child $repeat?

as in a html structure like

<node class="cluster"> //  first repeat - thinks rows
        <node class="particle"></node> // second repeat  -- think columns 
    </node>

and .js

behaviors: {

.cluster': {

        '$repeat': function(s_array) {
               var result = [];
               for (var i = 0; i < s_array.length; i++) { result.push({}); } 
               return result;
        },
        'position': function($index) 
                return [ s_array[$index][1], ];  
        },

},
'.particle': {

        '$repeat': function(s_array) {
            var result = [];
            for (var i = 0; i < s_array[PARENTINDEX][2]; i++) { result.push({}); } 
            return result;
        },
        'position': function() {
                return [$index, 0];      
        },

},

states: {

  s_array : [[1,11,8],[2,9,13],[2,9,23],[3,7,13],[4,6,19],[5,5,19],[6,4,8],[6,19,5],[7,4,7],[7,21,2],[8,4,6]]  

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions