javascript - ReactJs check all checkboxes -


i have select component rendering in table header, check of checkboxes on page when checked, if 1 of checkboxes unchecked select unselect too:

var selectall = react.createclass({  handler: function(e) {      e.target.value;     e.preventdefault();      channel.publish({         channel: "contact",         topic: "selectall",         data: {             contacts: this.props.data         }     }); },  render: function() {      console.log(this.props.data.children);      var id = this.props.contacts;     var isselected = this.props.data.isselected;      return (         <div classname="contact-selector">             <input type="checkbox" checked={isselected}                 onchange={this.handler} />         </div>     ); },  }); 

my checkboxes rendered in each table row:

var contactselector = react.createclass({  getinitialstate: function() {     return {         selectedcontacts:[]     }; },  handlechange: function(e) {     var id = e.target.attributes['data-ref'].value;      if (e.target.checked === true){         contactchannel.publish({                     channel: "contact",                     topic: "selectedcontact",                     data: {                         id: id                     }});     } else{         contactchannel.publish({             channel: "contact",             topic: "deselectedcontact",             data: {                 id: id             }});     } },  render: function() {      var id = this.props.data.id;     var isselected = this.props.data.isselected;      return (         <div classname="contact-selector">             <input type="checkbox"                 checked={isselected} data-ref={id}                 onclick={this.handlechange} />         </div>     ); }  }); 

can please tell me how setup check all? using state or refs etc


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -