0

Trying to add to a store on click from an input. There would be multiple inputs with different parts of an objects info. How can I grab in input data from a method?

In this case, I'm working with packets via a store

<input label="Packet Name" v-model="packets.name"  required><br>
<input label="Packet Name" v-model="packets.folder"  required><br>
<button @click="addPacket">Add</button>

On the addPacket call how do I get the input data?

Full jsfiddle : https://jsfiddle.net/tga9sfcm/1/

1 Answer 1

1
  • I added two data props to the app: name and folder.
  • Changed v-model binding to this two props.
  • Dispatched an action on button click.

Here is a working fiddle

Also, note that you dispatch Actions and commit Mutations. You had your action dispatching a mutation: store.dispatch('ADD_PACKET', packet)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.