Skip to content

Instantly share code, notes, and snippets.

@onefriendaday
Created November 20, 2018 14:27
Show Gist options
  • Save onefriendaday/3bbed56c70f7b94227d87def0154637b to your computer and use it in GitHub Desktop.
Save onefriendaday/3bbed56c70f7b94227d87def0154637b to your computer and use it in GitHub Desktop.
const Fieldtype = {
mixins: [window.Storyblok.plugin],
template: `<div>
<div v-if="modalIsOpen">Modal is open</div>
<div v-if="!modalIsOpen">Modal is closed</div>
<a @click="doOpen">Open modal</a>
<a @click="doClose">Close modal</a>
<select v-model="options"><option value="1"></option></select>
</div>`,
data() {
return {
modalIsOpen: false,
option: '1'
}
},
methods: {
initWith() {
return {
plugin: 'example_plugin',
example: 'Hello world!'
}
},
doOpen() {
this.$emit('toggle-modal', true)
this.modalIsOpen = true
},
doClose() {
this.$emit('toggle-modal', false)
this.modalIsOpen = false
},
pluginCreated() {
console.log('plugin:created')
}
},
watch: {
'model': {
handler: function (value) {
this.$emit('changed-model', value);
},
deep: true
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment