I am trying to change the state of a checkbox:
var React = require('react');
var UserTable = React.createClass({
handleCheckboxChange: function(field) {
return function(e) {
var value = !e.target.checked;
// this updates the state in the parent module
this.props.onUserUpdate(field, value);
// this persists the state to the server
this.props.onUserSave(field);
}.bind(this);
},
render: function() {
var user = this.props.data;
return (
<div className="ui toggle checkbox">
<input type="checkbox" onChange={this.handleCheckboxChange("topup_enabled")} checked={user.topup_enabled} />
<label></label>
</div>
);
}
});
Debugging this, I see that handleCheckboxChange
is never being called.
Any idea why ?
Aucun commentaire:
Enregistrer un commentaire