javascript - Call method of parent when child is dynamically inserted -
i have "modal" component , element dynamically insert "childs" on modal. how call method of parent element child of modal:
class parent extends component { constructor(props) { super(props); this.state = { 'view_addevent': false, }; this.addeventadhoc = this.addeventadhoc.bind(this); this.closeeventadhoc = this.closeeventadhoc.bind(this); this.searchadhocevent = this.searchadhocevent(this); } addeventadhoc() { this.setstate({ view_addevent: true }); } closeeventadhoc() { this.setstate({ view_addevent: false }) } searchadhocevent(event) { console.log(event.keycode); } render() { return ( <main id='main-content'> <modal show={this.state.view_addevent} autocomplete={ this.searchadhocevent } close={ this.closeeventadhoc }> <div classname='form-group'> <input id='event-adhoc-search' onkeypress={(e) => this.props.autocomplete(e) } classname='form-control' type='text' /> </div> </modal> </main> ); } }
Comments
Post a Comment