Advertisement
Guest User

Untitled

a guest
Aug 12th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var SelectHund = React.createClass({
  2.               getInitialState: function() {
  3.                 return {
  4.                   hunde:{}
  5.                 };
  6.               },
  7.               componentDidMount: function(){
  8.                 var that = this;
  9.                 $.ajax({
  10.                   type: "POST",
  11.                   url: "/foodoo/index.php?method=getDogs",
  12.                   data: JSON.stringify(planData),
  13.                   success: function(response){
  14.                     var hunde = JSON.parse(response);
  15.                     console.log(hunde);
  16.                     if(hunde.length >= 1){
  17.                       // var POS = hunde.map(function(i){
  18.                       //     console.log(i);
  19.                       //     return  <option key={i.id} value={i.weight}>i.name</option>;
  20.                       // });
  21.                       that.setState({
  22.                         hunde: hunde
  23.                       });
  24.                     }
  25.                   },
  26.                   error: function(){
  27.                   }
  28.                 });
  29.               },
  30.               render: function(){
  31.                 // var that = this;
  32.                 // $.ajax({
  33.                 //   type: "POST",
  34.                 //   url: "/foodoo/index.php?method=getDogs",
  35.                 //   data: JSON.stringify(planData),
  36.                 //   success: function(response){
  37.                 //     var hunde = JSON.parse(response);
  38.                 //     // console.log(hunde);
  39.                 //     if(hunde.length >= 1){
  40.                 //       var POS = hunde.map(function(i){
  41.                 //           // console.log(i);
  42.                 //           return  <option key={i.id} value={i.weight}>i.name</option>;
  43.                 //       });
  44.                 //       return(<select onChange={that.props.changeHund} className="selectHund" name="hund">{POS}</select>);
  45.                 //     }
  46.                 //   },
  47.                 //   error: function(){
  48.                 //   }
  49.                 //});
  50.                 if(this.state.hunde.length <= 0){
  51.                   return(<div>test</div>);
  52.                 }else{
  53.                   // console.log(this.state);
  54.                   // console.log(this.state.hunde);
  55.                   var POS = this.state.hunde.map(function(i){
  56.                       console.log(i);
  57.                       return  <option key={i.id} value={i.weight}>i.name</option>;
  58.                   });
  59.                   return(<select className="selectHund" name="hund">{POS}</select>);
  60.                 }
  61.               }
  62.             });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement