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

Working famousEach example #261

Open
igorkrumpak opened this issue Jul 20, 2015 · 6 comments
Open

Working famousEach example #261

igorkrumpak opened this issue Jul 20, 2015 · 6 comments

Comments

@igorkrumpak
Copy link

Can you please help me with famousEach in my project. Currently I have this.

template(name='Content')
    +famousEach articles
        +Node size='A:50;A:50'
            +DOMElement
                | Item: #{title}

I get error "Uncaught TypeError: Cannot read property 'addedAt' of undefined"

Can you can help me?

@gadicc
Copy link
Owner

gadicc commented Jul 24, 2015

Hey @igorkrumpak. The forums might be a better place to get help, although I do agree we're lacking in examples which is possibility better tracker on GitHub. Did you see all the Fview Lab examples? The "period table" and "custom layout" pads give examples of using famousEach.

For your particular issue, where are you including the "Content" template? Is it directly below a +Scene, +Node or some wrapped Layout?

@igorkrumpak
Copy link
Author

Yes i saw exemples. You can only use famousEach inside custom layout? My current code is this.

body
    +Scene
        +Node size=reactiveNavigationSize position=reactiveNavigationPosition
            +DOMElement
                +Navigation
        +Node size='A:100;P:100' position=reactiveMenuPosition
            +DOMElement class="blue-bg"
                +Menu
        +Node size=reactiveContentSize position=reactiveContentPosition 
            +DOMElement
                +Content

template(name='Content')
    +famousEach articles
        +Node size='A:50;A:50'
            +DOMElement
                | Item: #{title}

@gadicc
Copy link
Owner

gadicc commented Jul 25, 2015

You don't have to use a custom layout, but without a layout, everything will render on top of each other. To be honest, the new version of famous came quite bare.... if you're familiar with the old version, I'm going to write our own SequentialLayout and other views for famous-views, until famous provide something better.

Back to your code, the issue is you're trying to add Node's to a DOMElement... this isn't possible, but I agree we should have a better error here. If you drop the DOMelement that's 2nd from the bottom in your body, it will work (the Node's in Content will be added to the bottom Node in body.

In case you're purposefully trying to enclose all the Content DOMElement's in a parent DOMElement, the way to do this (in famous) is to still add the child nodes do the Node that has the DOMElement, not to the DOMElement itself. But you shouldn't do that unless you have a good reason to.

Did that all make sense? :)

@igorkrumpak
Copy link
Author

Yes it did!!!!

Ok, I added famouseEach directly to node and it's working now. The only problem I have now is that items are overlapping.

screenshot from 2015-07-25 12 40 11

@gadicc
Copy link
Owner

gadicc commented Jul 25, 2015

Great stuff :) Yeah, what you're experiencing is what I described... nodes by default will overlap. The old version of Famous came with a few basic layouts built in, but not the new version. The simple "each node next to each other" layout was called SequentialLayout, and I'm just going to write this myself and put it in the next version of famous-views.

@igorkrumpak
Copy link
Author

Ok tnx. Will wait then on next version!

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

2 participants