samedi 25 novembre 2017

My textarea input is not be empty after send message using Vue

I am using laravel and Vue. I have created a messenger application. Everything is done. But I am facing a problem. That is, after press enter button, message goes to the desired person. But the message still be available in the input filed until I refresh the page. Here is my html code.

<input type="hidden" v-model="conID">
<textarea class="col-md-12 form-control" v-model="msgFrom" @keydown="inputHandler" 
style="margin-top: 15px;border: none; resize: none;"></textarea>

Here is my Vue code.

   inputHandler(e){
        if(e.keyCode === 13 && !e.shiftkey){
            e.preventDefault();
            this.sendMsg();
        }
    },
    sendMsg()
    {
        if(this.msgFrom){
            axios.post('http://localhost:8000/sendMessage',{
                conID:this.conID,
                msg:this.msgFrom
            })
    .then(function(response){
        console.log(response.data);

        if(response.status===200){
            app.singleMsgs = response.data;
        }
    })
    .catch(function (error){
        console.log(error);
    });
        }

Can anyone please help me. Just how I can make textarea empty after sending a message. Thank's in advance.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2AaiCF6
via IFTTT

Aucun commentaire:

Enregistrer un commentaire