dimanche 5 février 2017

Handling enter key event in ember

I have a component in my application.It have a form with text fields.It will have a submit button.When submit is pressed it will send a post request to the server.I also handled a keyboard event in components js file.When enter is pressed it will send a post request to the server.When the enter key is pressed two times continuously it is making two post request to the server with first request success and second request failed. I want to make my app in such away even if the user presses the enter key two times continuously it should send only one post request to the server.Can any one help me solve this issue.Thanks in advance.

components js file export default Component.extend({ keyDown:function(event){

    let self = this;
    if(event.keyCode === 13){
            self.send('submitform'); 
            return false;
        }

actions: {
    submitform(){
    //logic to handle the post request to the server    
}   

}




Aucun commentaire:

Enregistrer un commentaire