Answer the question
In order to leave comments, you need to log in
How to apply two different methods to form submission - depending on the condition?
There is a form to which I apply the submit method
<textarea v-on:keypress.enter.prevent="input.length && menMessage()" id="chat_msg" placeholder="" v-model="input"></textarea>
<textarea v-on:keypress.enter.prevent="input.length && womenMessage()" id="chat_msg" placeholder="" v-model="input"></textarea>
Answer the question
In order to leave comments, you need to log in
I wouldn't put all the logic in the event handler here.
And I would just make a method sendMessage()
inside which I would check the user's gender and perform the necessary actions. But here already you will need to think about where and how you will store the user's gender.
methods: {
sendMessage() {
if (this.data.isMale) {
// do something for men
} else {
// do something for women
}
},
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question