Closed dalezak closed 4 years ago
I don't know vue-colcade, but if you could make a small app that showcases the issue so I can fiddle with it, that would be great.
Hi @excid3, any help would be greatly appreciated! 🙏
Here's the repo https://github.com/dalezak/Rails_Vue_Colcade.
And here's the demo https://rails-vue-colcade.herokuapp.com.
Source Files
Recreate Bug
This is fantastic. Thanks @dalezak!
Alrighty, so confirmed this isn't anything to do with vue-turbolinks, and I don't think it's really an issue with vue-colcade either, just your code.
You're creating a colcade instance and never tearing it down or updating it in your code. You need to update or destroy it when the component is destroyed.
vue-colcade caches the instance internally, so it keeps track of the first instance and never creates a second one since you're missing the destroy.
This solves your problem:
export default {
props: {
items: {
type: Array,
required: true
}
},
mounted() {
this.$colcade.create({
name: "cards",
el: "#cards",
config: {
columns: ".col",
items: ".card"
}
});
},
destroyed() {
this.$colcade.destroy("cards")
}
};
Same rule as always with Turbolinks: Make sure you setup when it mounts and cleanly teardown when you leave the page.
Adding a cleanup before the component is gone fixes it. 👍
Amazing, thank you @excid3!!
I'm having an issue using
Rails
+Vue
+Turbolinks
+Colcade
, to position a grid of cards.I have a simple grid of cards that loads fine initially via
vue-colcade
, however upon returning to the listing via the back button, the cards are not repositioned.Our Vue is setup using
vue-turbolinks
as suchThe component looks like
I posted an issue on vue-colcade but think the problem is related to
vue-turbolinks
.