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

Is there a v-for example looping an array of objects? #7

Closed
travbus opened this issue Feb 16, 2019 · 2 comments
Closed

Is there a v-for example looping an array of objects? #7

travbus opened this issue Feb 16, 2019 · 2 comments

Comments

@travbus
Copy link

travbus commented Feb 16, 2019

I can't seem to get this to work with a array of ojects "feedPosts" or even feedPosts.length which would equals 2. My {{val}} loops and displays object fine. But I get a error
** scrollama error: no step elements.**
It will not call handler function. Any Ideas Thanks
https://codesandbox.io/s/4270xl6oz0 is the snippet I was using

Update So I can get a static array of objects to work. I can't get a ajax loaded arrray of objects to work

<Scrollama :debug="true" :offset="0.8" @step-enter="handler">
      <div
        class="step"
        v-for="(val, n) in feedPosts"
        :key="n"
        offset="0.5"
        :data-step-no="n"
      >
        step {{ n }} {{val}}
      </div>
    </Scrollama>
@vgshenoy
Copy link
Owner

Scroll interactions are setup when <Scrollama> is mounted, so if feedPosts is an empty array, there won't be any step elements.

The easiest way to solve this is to render <Scrollama> only when feedPosts is populated.

<Scrollama v-if="feedPosts.length" @step-enter="handler">
...
</Scrollama>

@travbus
Copy link
Author

travbus commented Feb 18, 2019

Oh man so simple this totally worked bless you !!!

@travbus travbus closed this as completed Feb 18, 2019
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