在反应js中对模态创建put(更新)方法

时间:2017-05-16 08:38:32

标签: javascript asp.net api reactjs web

大家好我当前正在研究reactjs上的更新方法但是它不能用于我的模态我不知道哪个部分我弄错了请帮帮我这么迷失...

代码的这一部分是模态

的地方
<div className="modal fade" id="UpdateEmployee" role="dialog">
         <div className="modal-dialog">
           <div className="modal-content">
              <div className="modal-header">
                 <button type="button" className="close" data-dismiss="modal">&times;</button>
                <h4 className="modal-title">Update Employee</h4>
          </div>
          <div className="container">
          <form name="Employee" className="form-horizontal" onSubmit={this.handleSubmitUpdate}>
            <div className="modal-body">

                <table> 
                <tbody>

                <tr>
                <td>Name</td>
                <td> 
                <input type="text" 
                       value={this.state.Employee_Name} 
                       onChange={this.handleNameChange}
                       name="Employee_Name"
                       /> 
                </td>
                </tr>
                <tr>
                <td>Address</td>
                <td>
                <input type="text"
                       value={this.state.Address} 
                       onChange={this.handleAddressChange}
                       name="Address"
                       />
                </td>
                </tr>
                <tr>
                <td>Department</td>
                <td>
                <input type="text"
                       value={this.state.Department} 
                       onChange={this.handleDepartmentChange}
                       name="Address"
                       />
                </td>
                </tr>
                </tbody>
                </table>
                </div>
             </form>  </div>
            <div className="modal-footer">
            <botton className="btn btn-info"  id="employee_submit" onclick={this.handleSubmitUpdate.bind(this,this.state.Employee_ID)}> Update Employee</botton>
              <button type="button" className="btn btn-default" data-dismiss="modal" >Close</button>

并且这部分是put fetch的代码,但它现在正在工作,我不知道代码的哪一部分不起作用

handleOnclick(id,name,address,department) {


 this.setState({
    Employee_ID : id,
    Employee_Name: name,
    Address: address,
    Department: department,
  });
  }
}

const Form = React.createClass({

handleSubmitUpdate(data) {
        Employee (this.state.Employee_Name, data);
        Employee (this.state.Address, data);
        Employee (this.state.Department, data);
    },
    componentWillReceiveProps(props) {
        this.setState(props);
    }
export function Employee(id, data) {
  debugger
         return fetch('http://localhost:5118/api/employeedetails/PutEmployeeDetail/'+ id, {
        method: 'PUT',
        mode: 'CORS',
        body: JSON.stringify(data),
        headers: {
            'Content-Type': 'application/json'
        }
    }).then(res => {
        return res;
    }).catch(err => err);

0 个答案:

没有答案