javascript - Clear reactJs textarea after submit -


i have following form component in skylight dialog, after submit, if dialog reopened containing form, contains previous submitted value. can please tell me how stop , clear textarea value everytime dialog opened?

here component:

var addnoteform = react.createclass({   componentdidmount: function() {          react.finddomnode(this.refs.notes).value = ""; }, handlesubmit: function (event) {     event.preventdefault();      var notes = react.finddomnode(this.refs.notes).value;      var details = {         studentid: this.props.studentid,         schoolid: this.props.schoolid,         notes: notes     };      this.props.onsubmit(details); },  render: function() {     return (         <form classname="pure-form pure-form-aligned"             onsubmit={this.handlesubmit}>             <div classname="pure-control-group">                 <label htmlfor="notes">note</label>                 <textarea ref="notes" id="notes" placeholder="note..." >                 </textarea>              </div>             <div classname="pure-controls">                 <input type="submit" value="save" />             </div>         </form>     ); } });  module.exports = addnoteform; 

basically form not getting unmounted. writing code in componentdidmount not make sense. quick fix problem clear textarea box after read value in handle submit method

handlesubmit: function (event) {   event.preventdefault();    var notes = this.refs.notes;    var details = {     studentid: this.props.studentid,     schoolid: this.props.schoolid,     notes: notes.value   };    notes.value = ""; // unset value   this.props.onsubmit(details); }, 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -