panthro
panthro

Reputation: 24061

Binding a button to a model

I have bound a checkbox (output from options data in a loop):

<input type="checkbox" v-model="option.active">
options: [
    {
        name: 'one',
        active: false,
    },
    {
        name: 'two',
        active: false,
    },
    ....
]

I also want a button to be able to turn off the checkbox.

How can I also bind a button to the model?

Upvotes: 0

Views: 55

Answers (1)

Atu Lrnt
Atu Lrnt

Reputation: 111

You have to use the click event of the button:

<button v-on:click="option.active = false">Click</button>

or

<button @click="option.active = false">Click</button>

Upvotes: 1

Related Questions