Skip to content

Instantly share code, notes, and snippets.

@cristijora
Created August 26, 2019 09:49
Show Gist options
  • Save cristijora/54ac2fead1c895498a6f67d1c35a60e9 to your computer and use it in GitHub Desktop.
Save cristijora/54ac2fead1c895498a6f67d1c35a60e9 to your computer and use it in GitHub Desktop.
Collapse menus Vue Paper Dashboard PRO
// SidebarPlugin/index.js
const SidebarStore = {
// other code,
linksStore: [],
addSidebarLink(link) {
this.linksStore.push(link)
},
removeSidebarLink(link) {
const index = this.sidebarLinks.indexOf(link)
this.linksStore.splice(index, 1)
},
collapseAllMenus() {
this.linksStore.forEach(link => {
link.collapsed = true
})
}
}
// SidebarItem.vue
methods: {
//other code
collapseMenu() {
this.$sidebar.collapseAllMenus()
this.collapsed = !this.collapsed
}
},
mounted() {
// other code
this.$sidebar.addSidebarLink(this)
},
destroyed() {
// other code
this.$sidebar.removeSidebarLink(this)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment