meteor-mantra-kickstarter icon indicating copy to clipboard operation
meteor-mantra-kickstarter copied to clipboard

Mantra and Astronomy's isModified function with Save button

Open jaredtmartin opened this issue 7 years ago • 0 comments

Forgive me if this is the wrong place to ask this question, but I'm trying to figure out the best way to have a save button appear on rows that have been modified. Right now I have something like the following:

{parts.map(part => {
              debugger;
              const saveButton = part.isModified() ? (
                <Col md={1}>
                  <Button onClick={this.savePart.bind(this)} bsStyle="primary" type="button"><i className="fa fa-save" /></Button>
                </Col>
              ) : '';
              return (
                <Row key={part._id}>
                  <Col md={3}>
                    <FormGroup>
                      <FormControl ref="theme" type="text" placeholder="Theme" value={part.theme} onChange={this.changeField.bind(this, 'theme', part)} />
                    </FormGroup>
                  </Col>
                  // More fields here//
                  {saveButton}
                </Row>

in my changeField event handler I'm doing this:

changeField(field, obj, event){
    obj[field]=event.currentTarget.value;
  }

The problem is that the component is not getting re rendered when a field is changed, so the saveButton never appears. Should I be doing this differently?

jaredtmartin avatar Oct 11 '16 15:10 jaredtmartin