var RecordView = React.createClass({ getInitialState: function() { return { record: {} } }, loadRecord: function(id) { this.setState({ record: {} }); $.ajax({ url: '/api/record/' + id, success: function(data) { this.setState({ record: data }); }.bind(this), error: function(xhr, status, error) { console.error(xhr, status, error) }.bind(this) }); }, componentDidMount: function() { if (this.props.id == "new") { this.setState({ record: this.props.record || { Id: 0, Brand: 'Övriga', Cartype: 'Övriga', Text: '' }}); } else { this.loadRecord(this.props.id); } }, componentWillReceiveProps: function(props) { if (props.id == "new") { this.setState({ record: props.record || { Id: 0, Brand: 'Övriga', Cartype: 'Övriga', Text: '' }}); } else { this.loadRecord(props.id); } }, render: function() { if (this.props.id && this.state.record != null) { return (
Den efterfrågade posten kunde inte hittas.
); } }, renderTitle: function() { if (this.props.id == "new") { return