Created
September 30, 2019 19:20
-
-
Save onefriendaday/f45567f9156ade7b1f327db45d22fbea to your computer and use it in GitHub Desktop.
Example for getting filtered selectbox
This file contains 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
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