2016-10-26 6 views
0

マスタブレードから開いている部分に応じて、マスタブレードからデータを渡そうとしています。あなたは、私は2つの場所にcustomer.layouts.partials.carouselを使用しています見ることができるように、Laravel - マスタブレードからパーシャルへのデータの受け渡しがすべてのビューで機能しない

<div id="main-section"> 
     @section('topBar') 
     @include('customer.layouts.partials.top-bar') 
     @show 

     @section('header') 
     @include('customer.layouts.partials.header') 
     @show 

     @section('carousel') 
     @include('customer.layouts.partials.carousel', ['function' => 'drawer']) 
     @show 
    </div> 

    <div id="drawer"> 
     <div id="item-detail"> 
     </div> 
     <div id="item-detail-carousel"> 
     @section('carousel') 
      @include('customer.layouts.partials.carousel', ['function' => 'itemDetail']) 
     @show 
     </div> 
    </div> 

ので:これが私のマスターブレードの一部です。 は、私はこのように私の部分にデータを受信して​​います:

 <div class="swiper-container {{ $function }}"> 
      <div class="swiper-wrapper"> 
      @foreach($issues as $issue) 
       <div class="swiper-slide"> 
       <img 
        src="/imagecache/large/{{ $issue->first()->image }}" 
        onclick="{{ $function }}(
        '{{ $issue->first()->magazine->id }}', 
        '{{ $issue->first()->magazine->name }}', 
        '{{ $issue->first()->magazine->summary ?: '' }}', 
        '{{ $issue->first()->magazine->image ?: '' }}', 
        '{{ $issue->first()->image }}' 
        )" 
        > 
       </div> 
      @endforeach 
      </div> 
     </div> 

本部#drawerが最初に隠されている、display:noneを持っており、それがmain-sectionスライダーで画像をクリックして上に示されています。そして、#drawermain-sectionでスライドを取得します。しかし、クロムの要素を調べると、main-sectiondrawerセクションの両方で、渡されたデータがdrawerであることがわかります。 #drawerにはデータがありません['function' => 'drawer']私はそれを考えました。 どうすれば実現できますか?

答えて

1

@section指示がどのように機能するのか誤解していると思います。

最初に、同じ名前の@sectionディレクティブを複数持つことはできません(HTMLのIDのように考えてください)。また、もしあなたが@extendでファイルを拡張しようとしないなら、@sectionの使用にはあまり意味がありません。

@include('...')の周辺から@sectionディレクティブを削除すると正常に動作するはずです。

希望すると便利です。

関連する問題