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

Load dynamic data into vue-flickity and Firefox bug #40

Open
juanbrujo opened this issue Jul 27, 2018 · 6 comments
Open

Load dynamic data into vue-flickity and Firefox bug #40

juanbrujo opened this issue Jul 27, 2018 · 6 comments

Comments

@juanbrujo
Copy link

This is not a bug, but a solution after 2 days trying to fix this thing.

Using this component and axios, I retrieve data, use v-for and refresh vue-flickity but I had problems rebuilding the carousel. Also, getting that data and using created () exploded in Firefox and coudn`t create the carousel.

Solution:

axios(
    {
      method: .....m
      url: ....,
      data: ....
    })
    .then(response => {
      if (response && response.status === 200) {
        this.myData = response.data // this will be used in v-for inside flickity
      } else {
        // raven....
      }
    })
    .then(response => {
      this.$nextTick(function () { // the magic
        this.$refs.flickity.rerender()
      })
    })
    .catch((error) => {
      // raven
    })
<flickity ref="flickity" :options="myOptions">
  <div class="carousel-cell" v-for="item in myData" :key="item.id">
      <span class="name">{{ item.names }} {{ item.father_surname }}</span>
  </div>
</flickity>
@jian11231
Copy link

I have same problem with you, but after i try the solution above, the error of " Cannot read property 'rerender' of undefined" was returned

@juanbrujo
Copy link
Author

@jian11231 you must have a referer, see ref="flickity" in the component and this.$refs.flickity.rerender()

@aghouseh
Copy link

aghouseh commented Jan 3, 2019

I'm not seeing any reactive updates to the slider contents. It works on page load but as soon as I update the content of the slider, the parent component node is empty.

      <Flickity ref="flickity" :options="flickityOptions">
        <div v-for="image in images" :key="image" class="QuickBuy-image">
          <img :src="image" />
        </div>
      </Flickity>

image

@juanbrujo
Copy link
Author

juanbrujo commented Jan 3, 2019

@aghouseh the :key in a loop in Vue usually receives and int (unique id), so try with:

<div v-for="image in images" :key="image.id" class="QuickBuy-image">
  <img :src="image" />
</div>

@yeyuguo
Copy link

yeyuguo commented Nov 19, 2020

  1. 先移除旧实例
  2. 再重新获取数据【重新渲染】

@awatertrevi
Copy link

I'm not seeing any reactive updates to the slider contents. It works on page load but as soon as I update the content of the slider, the parent component node is empty.

      <Flickity ref="flickity" :options="flickityOptions">
        <div v-for="image in images" :key="image" class="QuickBuy-image">
          <img :src="image" />
        </div>
      </Flickity>

image

Same here. Did you manage to find a fix?

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

5 participants