I'm new to Vue. I can not remove an item from a DOM, in Vue.js Javascript file. I successfully managed to make an ajax post request, which removes a specific record from my database.
Once it's removed, I need to remove it from a DOM, so it won't shop up without need to reload the same page - I guess you know what I mean.
I can do it in jQuery, but I wonder how it should be done in Vue.js actually ?
Here is my portion of the code:
// SOME CODE BEFORE ...
onSubmit: function(e){
e.preventDefault();
$tablerow = this.el.parentNode.parentNode;
// Assign a correct submit request type and url
this.vm
.$http[this.getRequestType()](this.el.action)
.then(this.onComplete.bind(this))
.catch(this.onError.bind(this))
;
},
onComplete: function(){
// Remove the item from a DOM <<< I NEED TO REMOVE PARENT <tr/> ELEMENT
$(this.el).closest('tr').fadeOut(300, function(){
this.remove();
});
// If complete message exists, use it as a feedback
if(this.params.complete){
alert(this.params.complete);
}
},
// SOME CODE AFTER ...
Any suggestion please ? Sorry if my question is dumb, but I have not best knowledge in programming.
.remove()is in the Javascript capacity. If you were to, however, say$(this).remove()that would be using.remove()in the jQuery sense of the function. Also, it should be noted that jQuery is also built around Javascript