Skip to content

Instantly share code, notes, and snippets.

@onefriendaday
Created September 30, 2019 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onefriendaday/f45567f9156ade7b1f327db45d22fbea to your computer and use it in GitHub Desktop.
Save onefriendaday/f45567f9156ade7b1f327db45d22fbea to your computer and use it in GitHub Desktop.
Example for getting filtered selectbox
const Fieldtype = {
mixins: [window.Storyblok.plugin],
template: `<div><select v-model="model.example"><option :value="item.uuid" :key="item.uuid" v-for="item in stories">{{item.name}}</option></select></div>`,
data() {
return {stories: []}
},
methods: {
initWith() {
return {
plugin: 'example_plugin',
example: 'Hello world!'
}
},
pluginCreated() {
this.api
.get('cdn/stories', {
'filter_query[color][in]': 'red'
})
.then((res) => {
this.stories = res.data.stories
})
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