Partial views with JavaScript in Laravel 5

余生颓废 提交于 2019-11-30 10:19:29

The solution to your problem is the @parent directive, which you have to use in your javascript sections.

test.page.blade.php

@extends('layouts.default')
@section('title', 'Poses')

@section('content')
    <div class="container">
        <div class="row">
            @include('test.partial.one')
            @include('test.partial.two')
        </div>
    </div>
@stop

@yield('javascript')

test.partial.one.blade.php

@section('content')
    <h1>One</h1>
@stop

@section('javascript')
    <script>Scripts from one</script>
    @parent
@stop

test.partial.two.blade.php

@section('content')
    <h1>Two</h1>
@stop

@section('javascript')
    <script>Scripts from two</script>
    @parent
@stop

For further reference: http://laravel.com/docs/5.0/templates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!