Created
September 30, 2015 00:41
-
-
Save gugl/cc0cf2983de47def471b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@TaskListBox = React.createClass | |
getInitialState: -> | |
taskLists: [] | |
componentDidMount: -> | |
$.ajax | |
url: this.props.url | |
dataType: 'json' | |
cache: false | |
success: (data) => | |
@setState | |
taskLists: data | |
error: (xhr, status, err) => | |
console.error @props.url, status, err.toString() | |
handleTaskListSubmit: (taskList) -> | |
$.ajax | |
url: this.props.url | |
dataType: 'json' | |
type: 'POST' | |
data: {task_list: taskList} | |
cache: false | |
success: (data) => | |
taskLists = this.state.taskLists.concat([data]) | |
@setState {taskLists: taskLists} | |
error: (xhr, status, err) => | |
console.error this.props.url, status, err.toString() | |
render: -> | |
`<div className="taskListBox"> | |
Hello, world! I'm a Task List Box! | |
<TaskListForm onTaskListSubmit={this.handleTaskListSubmit}/> | |
<h1>Task Lists</h1> | |
<TaskListList taskLists={this.state.taskLists} /> | |
</div>` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment