javascript - Mutliple event's to listen for in a input element (Reactjs) -


hello have input element this:

<input    type="text"    classname="form-control"    placeholder="search for..."    value={this.state.text}    onchange={this.handletextchange} /> 

i have button beside onclick make ajax call using input text search results.

what want not click event on pressing enter ajax call should go through tried this:

<input    type="text"    classname="form-control"    placeholder="search for..."    value=this.state.text}    onchange={this.handletextchange}    onkeydown={this.handleenter} /> 

but seizes work ideas's why?

remove e.preventdefault

handleenter: function (e) {   if (e.keycode == 13) {     var text = this.state.text.trim();     if(!text){       return;     }      this.props.ontextchange({ text: text });   } },  handletextchange: function (e) {   this.setstate({ text : e.target.value }); }, 

example


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -