I have a field where I can enter numbers
<input type="text" class="form-control" id="validationTooltip01" v-model="verse.number" required>
After saving the number in the database, I would like it to automatically increment.
For example:
If I input 1
and save the form, the next time I open the form the number should be 2
without me having to type it again each time.
Sample Code
data() {
return {
verse: {
number: '',
heading: '',
body: '',
book_id: '',
chapter_id: '',
}
}
},
submit: function(e) {
axios.post('/my_url', this.verse)
.then(res => {
this.isLoading = false;
$('#exampleModal').modal('toggle');
this.getVerses.push( res.data.verse );
this.verse = {
number: this.verse.number, // here
heading: '',
body: '',
book_id: this.verse.book_id,
chapter_id: this.verse.chapter_id,
};
})
.catch(error => {
// handle authentication and validation errors here
this.errors = error.response.data.errors
this.isLoading = false
})
}
I've tried several approaches but none of them worked as expected,
this.verse = {
number: this.verse.number +=1,
...
or
this.verse = {
number: this.verse.number +1,
...
Any suggestions?