Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$repeat does not repeat #72

Open
MichaelGradek opened this issue Aug 9, 2015 · 0 comments
Open

$repeat does not repeat #72

MichaelGradek opened this issue Aug 9, 2015 · 0 comments

Comments

@MichaelGradek
Copy link

If you run this example, Framework will only generate 1 div at position 50, 50 where I would expect it to create two, one at 0, 0 and the second at 50, 50. Also, the console.log($index) prints two 1's, instead of a 0 and a 1. Strange...

FamousFramework.component('m:test', {
    behaviors: {
        '.item': {
            '$repeat': [0, 1],
            'position': ($index) => {
                console.log($index);
                return [$index * 50, $index * 50]
            },
            'content': ($index) => {
                return `<div style="width: 50px; height: 50px; background-color: yellow">${$index}</div>`
            }
        }
    },
    events: {},
    states: {},
    tree: `
        <node class="item"></node>
    `
});

EDIT: Hmm… just saw this seems to happen whenever the list you try to repeat over does not contain objects… So for example if you '$repeat’: [0, 1] it does not seem to create two elements, but if instead you '$repeat’: [{foo: ‘hello’}, {foo: ‘world'}] then it does create two elements…!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant