I am trying to pass data from my master blade to the partial depending where it is open. This is part of my master blade:
<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>
So, as you can see I am using customer.layouts.partials.carousel
in two places.
I am receiving data in my partial like this:
<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>
Div #drawer
is hidden first, has display:none
, and it is shown on click on an image in the slider in the main-section
. And then #drawer
gets slides over the main-section
. But when I inspect the elements in the chrome I see that both in the main-section
and in the drawer
section, data that was passed is drawer
. The #drawer
didn't get data ['function' => 'drawer']
as I thought it would.
How can I achieve that?
I think you're misunderstanding how the @section
directive is meant to work.
For starters, you shouldn't have multiple @section
directives with the same name (think of it like ids with HTML
- there should only be one with that name). Also, if your not going to be extending files with @extend
there isn't much point in using @section
at all.
If you remove the @section
directives from around your @include('...')
then they should work fine.
Hope this helps!