Created
February 15, 2017 23:02
-
-
Save fpoirier1/13155858ec88c2a6cbbb253cb8625e9d to your computer and use it in GitHub Desktop.
Schedule Form Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component, PropTypes } from 'react'; | |
// Task component - represents a single todo item | |
export default class ScheduleField extends Component { | |
change(event){ | |
this.props.onChange({ | |
time : this.refs.timeInput | |
}) | |
} | |
render() { | |
var item = this.props.item; | |
return ( | |
<div> | |
Time : | |
<input ref="timeInput" type="text" value={item.time} onChange={this.change.bind(this)} /> | |
Name : | |
<input ref="nameInput" type="text" value={item.name} onChange={this.change.bind(this)}/> | |
</div> | |
); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createContainer } from 'meteor/react-meteor-data'; | |
import ScheduleField from './ScheduleField.jsx'; | |
export default ScheduleFieldContainer = createContainer((props) => { | |
const isValid = function(){ | |
console.log(this.refs.timeInput.value); | |
} | |
return { isValid }; | |
}, ScheduleField); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component, PropTypes } from 'react'; | |
import ScheduleField from './ScheduleField.jsx'; | |
// Task component - represents a single todo item | |
export default class ScheduleForm extends Component { | |
render() { | |
return ( | |
<section> | |
<header>Horaire</header> | |
<form onSubmit={this.props.submit}> | |
{this.props.items.map((item,i) => | |
<ScheduleFieldContainer key={i} item={item} /> | |
)} | |
</form> | |
</section> | |
); | |
} | |
}import { Meteor } from 'meteor/meteor'; | |
import { ScheduleItems } from '/modules/api/collections.js'; | |
import { createContainer } from 'meteor/react-meteor-data'; | |
import ScheduleForm from './ScheduleForm.jsx'; | |
export default ScheduleFormContainer = createContainer((props) => { | |
let items = [ | |
{time : "18h", name : "Présentation"}, | |
{time : "19h", name : "Commencement"} | |
]; | |
const submit = function(){ | |
console.log('submit'); | |
return false; | |
} | |
return { items, submit }; | |
}, ScheduleForm); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Meteor } from 'meteor/meteor'; | |
import { ScheduleItems } from '/modules/api/collections.js'; | |
import { createContainer } from 'meteor/react-meteor-data'; | |
import ScheduleForm from './ScheduleForm.jsx'; | |
export default ScheduleFormContainer = createContainer((props) => { | |
let items = [ | |
{time : "18h", name : "Présentation"}, | |
{time : "19h", name : "Commencement"} | |
]; | |
const submit = function(){ | |
console.log('submit'); | |
return false; | |
} | |
return { items, submit }; | |
}, ScheduleForm); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment