G
G
Garguly Magnievich2019-09-21 09:54:50
Vue.js
Garguly Magnievich, 2019-09-21 09:54:50

How to fire 2 @click events in Vue.js?

Using the Vuetify 2 library, the Item Groups component , but this task will work for all elements with toggle.
Posted the code here .
The objectives of the task are as follows:
1) On the @click="toggle" event, perform one more action (write the key into Vuex). I know that you need to create a method for this, but how to write this toggle action in the method?
2) How to assign an element index identical to the key property in the items array? I need to pass in Vuex not 0, 1 or 2, but the key property of the selected element.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
V
Vladimir Sartakov, 2019-09-21
@chuanyurug


You can simply list the methods separated by commas: *For toggle to work, you need to pass the $event event object, by default, when one method is registered, $event is passed automatically

A
Artur Karapetyan, 2019-09-21
@architawr

div(@click="multiplyActions")

methods: {
  multiplyActions() {
    this.foo();
    this.bar();
    this.baz();
  },

  foo() {
    console.log(123213);
  },
  
  .....
}

?

D
Dmitry Barkowski, 2019-09-21
@TypeOFF

In the example code, you are moving in the normal direction.
Nothing prevents you from expanding the logic of the method.

K
Kotaro Hiba, 2021-04-05
@lina666

if suddenly someone needs it, this is how you can do 2 methods for 1 event

<div
@click="sendRequest('DELETE', {ids: [deleteModal.itemId]}); deleteModal.show = false"
></div>

A
Aleksey-Nuzhdin, 2022-01-30
@Aleksey-Nuzhdin

In VUE3, the variant did not work for me: @click="foo, bar"
But it works fine, immediately with the call: @click="foo(), bar()"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question