<commit_before>var ListItem = React.createClass({
  render: function() {
    return (
      <li className="ListItem-title">{ this.props.item.title }</li>
    );
  }
});<commit_msg>Add ajax save to list item.<commit_after>var ListItem = React.createClass({
  inputChange: function(event) {
    this.state.hasChanged = true;
    this.setState({ value: event.target.value });
  },
  saveData: function() {
    if(this.state.hasChanged) {
      this.state.item.title = this.state.value;
      var stringData = JSON.stringify(this.state.item);
      var path = '/list_items/' + this.state.item.id;
      console.log(path);
      $.ajax({
        url: path,
        method: 'put',
        data: stringData,
        dataType: 'json',
        contentType: 'application/json',
        error: function(jqXHR, textStatus, errorThrown) {
          console.log('error', errorThrown);
        },
        success: function(data, textStatus, jqXHR) {
          console.log('success', data);
          this.setState({ hasChanged: false });
        }.bind(this)
      });
    }
  },
  getInitialState: function() {
    return {
      item: this.props.data,
      hasChanged: false
    }
  },
  render: function() {
    var saveButton = this.state.hasChanged ? <button onClick={ this.saveData } >Save</button> : '';
    return (
      <li className="ListItem-title">
        <input defaultValue={ this.props.data.title } value={ this.state.value } onChange={ this.inputChange } data-id={ this.state.item.id } />
        { saveButton }
      </li>
    );
  }
});
{'fraction_non_alphanumeric': 0.1549935149156939, 'fraction_numerical': 0.0, 'mean_word_length': 2.4988662131519273, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5518538', 'n_tokens_mistral': 480, 'n_tokens_neox': 479, 'n_words': 95}