Updated examples
This commit is contained in:
parent
e0148db11f
commit
b6c155a199
4 changed files with 33 additions and 23 deletions
|
|
@ -5,27 +5,23 @@
|
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/zepto/1.1.6/zepto.min.js"></script>
|
||||
<script src="../lib/php_crud_api_transform.js"></script>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
var PostList = React.createClass({
|
||||
displayName: 'PostList',
|
||||
url: 'http://localhost/api.php/posts',
|
||||
|
||||
getInitialState: function getInitialState() {
|
||||
url: '../api.php/posts',
|
||||
getInitialState: function() {
|
||||
return { posts: [] };
|
||||
},
|
||||
|
||||
componentDidMount: function() {
|
||||
$.post(this.url, {user_id:1,category_id:1,content:"from react"});
|
||||
this.serverRequest = $.get(this.url, function (data) {
|
||||
retrieveServerState: function() {
|
||||
this.serverRequest = $.get(this.url, function (data) {
|
||||
this.setState(php_crud_api_transform(data));
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
componentDidMount: function() {
|
||||
$.post(this.url, {user_id:1,category_id:1,content:"from react"}, this.retrieveServerState);
|
||||
},
|
||||
componentWillUnmount: function() {
|
||||
this.serverRequest.abort();
|
||||
},
|
||||
|
||||
render: function render() {
|
||||
var createPost = function(post) {
|
||||
return React.createElement(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue