2017-06-21 3 views
1

UPDATE:選択のonChange表ブレードビュー

https://mydomaine.eu/go/public/competition/search/equipes?poule_id=2

私が手に:私はpoule_idを変更したときに、私はのようなURLに直接アクセスしたときに、今私は、内部に何も空白のテーブルを取得
テーブル」 \ n \ n \ n \ n \ n "

選択欄に装備(チーム)を表示するブレードテーブルの結果を変更する機能を作ろうとしていますが、わからない瞬間は何も起こりませんどこで私は間違いを犯したのでしょうか?それはおそらくJavaScriptコードにあります

誰かがそれを修正するのに役立つ可能性があり

希望、私はこのような選択ボックスでpoule_idに応じて、私のテーブルを変更しようと事前

でのおかげでたくさん:

<select id="poule"> 
    @foreach($select_poules as $select_poule) 
     <option value="{{$select_poule->id}}">{{$select_poule->lb_poule}}</option> 
    @endforeach 
</select> 

私のテーブルが依存するチームが含まれていますpoule_id:

@foreach($equipes as $equipe) 
    <tr> 
    <td> 
     <a href="{!! route('club.show', $equipe->equipe->structure->id) !!}">{{$equipe->equipe->structure->nom_structure}}</a> 
    </td> 
    <td> 
     <a href="{!! route('equipe.show', $equipe->equipe->id) !!}">{{$equipe->equipe->lb_equipe}}</a> 
    </td> 
    <td> 
     {!! Form::text('nb_bonus') !!} 
    </td> 
    </tr> 
@endforeach 

ここに私のコントローラ:

public function searchEquipes(Request $request) 
{ 

    if ($request->has('poule_id')) { 

     $equipes = EquipePoule::where('poule_id' , $request->poule_id)->get(); 

     $competition = Compet::where('id' , 1)->first(); 

     $categorie_compet = CategorieCompet::pluck('lb_categorie_compet' , 'id'); 

     $categorie_age = CatgEquipe::pluck('lb_catg_equipe' , 'id'); 

     $structure_rattachement = Structure::select('num_structure', 'nom_structure' , 'id') 
      ->where('type_structure_id' , '1') 
      ->orWhere('type_structure_id' , '2') 
      ->orWhere('type_structure_id' , '3') 
      ->get() 
      ->mapWithKeys(function($i) { 
       return [$i->id => $i->num_structure.' - '.$i->nom_structure]; 
      }); 
     $poules = Poule::where(['compet_id' => $competition->id])->get(); 

     $rencontres = Rencontre::where(['compet_id' => $competition->id])->orderBy('dt_rencontre' , 'DESC')->get(); 

     $designations = RencontreOfficiel::where(['compet_id' => $competition->id])->get(); 

     $classements = Classement::where(['compet_id' => $competition->id])->orderBy('nb_point_classement' , 'DESC')->get(); 

     $equipe_to_select = Equipe::select('lb_equipe', 'structure_id' , 'catg_equipe_id' ,'id') 
      ->get() 
      ->mapWithKeys(function($i) { 
       return [$i->id => $i->lb_equipe.' - '.$i->structure->nom_structure.' - ' .$i->catg_equipe->lb_catg_equipe]; 
      }); 

     $stade = Stade::select('lb_nom', 'ville_stade' , 'cd_post_stade' , 'id') 
      ->get() 
      ->mapWithKeys(function($i) { 
       return [$i->id => $i->lb_nom.' - '.$i->ville_stade.' - '.$i->cd_post_stade]; 
      }); 



     $find_equipes = $competition->equipes; 

     $domicile = $find_equipes->mapWithKeys(function ($i) { 
      return [$i->id => $i->lb_equipe.' - '.$i->structure->nom_structure.' - ' .$i->catg_equipe->lb_catg_equipe]; 
     }); 


     //ON AFFICHE QUE LES EQUIPES ENREGSITRER DANS LE COMPETITION 
     $find_equipes = $competition->equipes; 
     $visiteur = $find_equipes->mapWithKeys(function ($i) { 
      return [$i->id => $i->lb_equipe.' - '.$i->structure->nom_structure.' - ' .$i->catg_equipe->lb_catg_equipe]; 
     }); 

     $select_poules = Poule::where('compet_id' , 1)->get(); 

     $journees = Journee::where('compet_id' , 1)->get(); 

     $journee_to_select = Journee::where('compet_id' , 1)->pluck('nm_journee' , 'id'); 


     return response()->json([ 

      'table' => view("competitions/show", compact('equipes' , 'competition' , 'categorie_age' , 'categorie_compet' , 'classements' , 'equipe_to_select' , 'structure_rattachement' , 'poules' , 'select_poules' , 'journee_to_select' , 'journees' , 'rencontres', 'designations' , 'stade', 'domicile' , 'visiteur'))->render(), 

     ]); 

    }else { 

     echo 'on trouve rien '; 
    } 

ここに私のjavascript:JSONにキャストする必要があるため、

<script> 
    $('#poule').change(function() { 
     $.ajax({ 
      type: 'GET', 
      dataType: "json", 
      url : 'search/equipes/', 
      data : { 
       poule_id : document.getElementById('poule').value 
      }, 
      success:function(data){ 
       $('#equipes').html(data.table); 
      }, 
     }); 
    }); 
</script> 
+0

これで、divコンテナにajaxを使ってビュー全体を注入しようとしていますか? JavaScriptコンソールまたはPHP側にエラーはありますか? – Asur

+0

はい正確に!問題は私がjavascriptやPHPのエラーを取得する –

+0

私は私の答えを更新して、それらのステップを試してみて、エラーがどこにあるのかを教えて、より良い答えを提供することができます。 – Asur

答えて

1

は、エラーのフィードバックを取得しないが、非常に奇妙ですが、私はあなたがHTMLにAjaxの機能に期待するデータ型を変更することで開始するとJavaScriptを一度HTMLにキャストしてください。

  • :それから私は失敗がどこにあるか確認するために、いくつかの手順に従ってしまう

    <script> 
        $('#poule').change(function() { 
         $.ajax({ 
          type: 'GET', 
          dataType: "html", 
          url : 'search/equipes/', 
          data : { 
           poule_id : document.getElementById('poule').value 
          }, 
          success:function(data){ 
           $('#equipes').html(data); 
          } 
         }); 
        }); 
    </script> 
    

    あなたのコントローラ:

    public function searchEquipes(Request $request) 
    { 
        if ($request->has('poule_id')) { 
         $equipes = $equipes = EquipePoule::wherePouleId($request->poule_id)->get(); 
         return view("competitions/show", compact('equipes'))->render(); 
        } 
    } 
    

    あなたのAJAXだから、このようになります。イベントはアヤックスに届いていますか?

  • ajaxはサーバーに到達していますか?
  • コントローラーを呼び出すサーバールーティングはありますか?
  • コントローラがビューを正しく戻していますか?
  • ajaxはDOMコンテナを更新していますか?

私にそれが失敗する点を教えてください。私は詳細を編集します。

+0

よろしくお願いします。更新があります!私は投稿を編集して、あなたがどこに問題があるかを知ることができれば幸いです –

関連する問題