Last active
May 29, 2019 22:52
-
-
Save LazyFatArrow/c1122bb0531f0efa0b5780cc15497899 to your computer and use it in GitHub Desktop.
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
<template> | |
<div> | |
<b-button @click="isModalVisible = true">Create Poll</b-button> | |
<b-modal | |
v-model="isModalVisible" | |
@ok="$emit('createPoll', pollForm)" | |
title="Create a new poll" | |
centered | |
> | |
<b-form-group label="Title"> | |
<b-form-input | |
v-model="pollForm.title" | |
/> | |
</b-form-group> | |
<b-form-group label="Description"> | |
<b-form-textarea | |
v-model="pollForm.description" | |
/> | |
</b-form-group> | |
<b-form-group label="Options"> | |
<b-form-input | |
v-model="pollForm.options[index].name" | |
v-for="(option, index) in pollForm.options" | |
:key="`poll-form-option-${index}`" | |
/> | |
</b-form-group> | |
<b-form-group> | |
<b-btn @click="addOption">Add Option</b-btn> | |
</b-form-group> | |
</b-modal> | |
</div> | |
</template> | |
<script> | |
export default { | |
methods: { | |
addOption() { | |
this.pollForm.options.push({ | |
name: '', | |
}) | |
}, | |
}, | |
data: () => ({ | |
isModalVisible: false, | |
pollForm: { | |
title: '', | |
description: '', | |
options: [ | |
{ | |
name: '', | |
} | |
], | |
}, | |
}) | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment