Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var SelectHund = React.createClass({
- getInitialState: function() {
- return {
- hunde:{}
- };
- },
- componentDidMount: function(){
- var that = this;
- $.ajax({
- type: "POST",
- url: "/foodoo/index.php?method=getDogs",
- data: JSON.stringify(planData),
- success: function(response){
- var hunde = JSON.parse(response);
- console.log(hunde);
- if(hunde.length >= 1){
- // var POS = hunde.map(function(i){
- // console.log(i);
- // return <option key={i.id} value={i.weight}>i.name</option>;
- // });
- that.setState({
- hunde: hunde
- });
- }
- },
- error: function(){
- }
- });
- },
- render: function(){
- // var that = this;
- // $.ajax({
- // type: "POST",
- // url: "/foodoo/index.php?method=getDogs",
- // data: JSON.stringify(planData),
- // success: function(response){
- // var hunde = JSON.parse(response);
- // // console.log(hunde);
- // if(hunde.length >= 1){
- // var POS = hunde.map(function(i){
- // // console.log(i);
- // return <option key={i.id} value={i.weight}>i.name</option>;
- // });
- // return(<select onChange={that.props.changeHund} className="selectHund" name="hund">{POS}</select>);
- // }
- // },
- // error: function(){
- // }
- //});
- if(this.state.hunde.length <= 0){
- return(<div>test</div>);
- }else{
- // console.log(this.state);
- // console.log(this.state.hunde);
- var POS = this.state.hunde.map(function(i){
- console.log(i);
- return <option key={i.id} value={i.weight}>i.name</option>;
- });
- return(<select className="selectHund" name="hund">{POS}</select>);
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement