Skip to content

Instantly share code, notes, and snippets.

@onefriendaday
Created April 19, 2018 14:06
Show Gist options
  • Select an option

  • Save onefriendaday/a6943a8d4c9dcd6321fd76ddbced3c57 to your computer and use it in GitHub Desktop.

Select an option

Save onefriendaday/a6943a8d4c9dcd6321fd76ddbced3c57 to your computer and use it in GitHub Desktop.
Folder Selector Plugin example
const Fieldtype = {
mixins: [window.Storyblok.plugin],
template: `<div><select class="uk-width-1-1" v-model="model.value">
<option :key="option.value" v-for="option in options">{{ option.name }}</option>
</select></div>`,
data() {
return {
options: []
}
},
methods: {
initWith() {
return {
plugin: 'folder-selector',
value: ''
}
},
pluginCreated() {
this.options = []
this.api.get('cdn/links').then((res) => {
for (let key in res.data.links) {
if (res.data.links[key].is_folder) {
this.options.push({name: res.data.links[key].name, value: key})
}
}
})
}
},
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