KeyPress event not working as expected in Ember

前端 未结 1 734
悲哀的现实
悲哀的现实 2021-01-15 03:35

What I want to do is, make an ajax call whenever user stops entering something in the \'projectname\' field & check it against database & show an kind of error messa

相关标签:
1条回答
  • 2021-01-15 04:08

    Key press is working as expected, key press happens before the textbox value has changed.

    It looks like key up isn't supported in the manner that you want tho. Fortunately it's really easy to override:

    App.KeyUpTextField = Em.TextField.extend({
      keyUp:function(event){
        this.sendAction('upKeyAction', event); 
      }
    });
    
    
    {{view App.KeyUpTextField value=projectname upKeyAction='checkName'}}
    

    BTW I'd do debounce or something like that in your keyUp function, it seems like it'd get a bit chatty to send the request on every keyup event.

    0 讨论(0)
提交回复
热议问题