Last active
January 17, 2019 21:50
-
-
Save DominikAngerer/eed8920dabbfae23b2c898ba7198fe85 to your computer and use it in GitHub Desktop.
Storyblok: Custom Field Modal Demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template> | |
| <div> | |
| <div v-show="!modalIsOpen"> | |
| Custom field is in sidebar / not in modal | |
| <button @click=openModal>Open</button> | |
| </div> | |
| <div v-if="modalIsOpen"> | |
| Custom field is in not in sidebar but in a modal | |
| <button @click=closeModal>Close</button> | |
| </div> | |
| </div> | |
| </template> | |
| <script> | |
| export default { | |
| mixins: [window.Storyblok.plugin], | |
| data() { | |
| return { | |
| modalIsOpen: false | |
| } | |
| }, | |
| methods: { | |
| initWith() { | |
| return { | |
| // needs to be equal to your storyblok plugin name | |
| plugin: 'my-plugin-name' | |
| } | |
| }, | |
| pluginCreated() { | |
| // eslint-disable-next-line | |
| console.log('plugin:created') | |
| }, | |
| openModal(){ | |
| this.$emit('toggle-modal', true) | |
| this.modalIsOpen = true | |
| }, | |
| closeModal(){ | |
| this.$emit('toggle-modal', false) | |
| this.modalIsOpen = false | |
| } | |
| }, | |
| watch: { | |
| 'model': { | |
| handler: function (value) { | |
| this.$emit('changed-model', value); | |
| }, | |
| deep: true | |
| } | |
| } | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment