0👍
The easiest way to stop this is adding data check. And condition check at top of your method.category_description !== undefined
. Btw, move your e.preventDefault()
to top too.
0👍
When you are clicking on Add Category
button, it is triggering the addCategory
along with your validation method.
The return value of validation method has no impact on triggering of addCategory
.
This issue can be handled in following ways.
- Call
addCategory
only when there is some valid data
<button type="submit" @click="category_description != undefined ? addCategory() : ''" class="btn btn-primary"> Add Category </button>
- Call the validation method inside addCategory and then proceed.
- [Vuejs]-If CORS if refusing my API request and I don't control the server, is there nothing I can do?
- [Vuejs]-Vuejs update a list in reactive manner
0👍
First of all do this:
- <button type="submit" @click="category_description !== undefined ? addCategory : ''" class="btn btn-primary"> Add Category </button>
+ <button type="submit" @click.prevent="addCategory" class="btn btn-primary"> Add Category </button>
and then in addCategory:
addCategory() {
if (!this.category_description) {
return;
} else {
// do your stuff here
}
}
- [Vuejs]-Axios GET request got error, but I see response in browser
- [Vuejs]-Webview not receiving post message data from web
Source:stackexchange.com