Answer the question
In order to leave comments, you need to log in
How to connect an event to a button by class name?
A script with an onClick event was written in react, js was compiled.
The question is how to implement an event for buttons by class name, but without creating the buttons themselves through a script.
Now it looks like this, and inside the buttons with the class name booking, other buttons are created, to which the event is set.
var App = React.createClass({
getInitialState() {
return { smShow: false};
},
showModal() {
this.setState({show: true});
},
hideModal() {
this.setState({show: false});
},
render() {
let smClose = () => this.setState({ smShow: false });
return (
<ButtonToolbar>
<Button bsStyle="primary" onClick={()=>this.setState({ smShow: true })}>
Contact Form
</Button>
<MySmallModal show={this.state.smShow} onHide={smClose}/>
</ButtonToolbar>
);
}
});
ReactDOM.render(<App />, document.getElementById('booking'));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question